PDA

View Full Version : @@identity on postgres?


unicef2k
09-24-02, 23:30
I'm suppose to migrate data at work from MS SQL server to Postgresql. Everything is done except, how can I obtain @@identity in postgresql?

Thanks in advance.

eperich
09-25-02, 04:58
I don't know anything about mssql

But you can find useful information at
Techdocs (http://techdocs.postgresql.org)

There are some scripts that make the migration and I think some tutorials

nate
11-30-04, 13:48
Probably long past resolved but might help someone else. Use sequences in postgres for id columns:


INSERT mytable(myid) VALUES (nextval('MySequence'));

SELECT currval('MySequence');

currval works like @@identity and will return the current value of the sequence in the same session.

http://database.sarang.net/database/postgres/aw_pgsql_book/node74.html#5906