I admit I'm still learning the ins and outs of PostgreSQL. I'm now working with ADOdb as well. I've got the following hang up:

I have a simple user's table (has 6 fields, one of which is an auto ID or "serial" field).

I'm able to insert into the table and the ID is incrementing.

I'm used to grabbing the auto incremented ID after the query, so my goal was to do something like this:

select currval('userkeeper_userID_seq')

But I get the following error:

Relation "userkeeper_userid_seq" does not exist

(I get this same error from phpPgAdmin).

I've read the tutorial on this site about using currval/nextval. I can do this:

SELECT * FROM "userkeeper_userID_seq"

And I can also do:

SELECT last_update FROM "userkeeper_userID_seq"

This does get me the last ID, but I'm not comfy if this will always be 100% accurate (say 2 inserts take place and brings back the latest ID but not my ID).

I've checked the permissions and I have given the web user what I believe is the needed permissions (update/select) on the sequence. I haven't figured out what's missing. The insert query is being run via ADOdb's Execute() function. Am I using the wrong function?

    Try and error won:

    SELECT currval('public."userkeeper_userID_seq"')

    That gave me what I was looking for...

      Write a Reply...