Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql last_insert_id() to postgres

Status
Not open for further replies.

axman505

Technical User
Jun 20, 2001
489
US
I am trying to figure out an equivalant function in postgresql for mysql last_insert_id .. i have seen curval() should do it, but i am relatively new to postgresql and having some problems. Can anyone offer any pointers? Thanks.
 
well curval is what you need if the id field is of type serial then find the sequence name (usually tableName_fieldName_seq)

and do SELECT currval('tableName_fieldName_seq');

this should be done after insert-ing in the table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top