11 Dec
2001
11 Dec
'01
3:20 p.m.
On Tue, 11 Dec 2001, Stephane Bortzmeyer wrote:
I have a SQL method which performs an INSERT in one table, followed by an INSERT into another table. The two INSERTs have to be in the same method because they need to be atomic.
In the first table, there is an auto-incrementing field that the PostgreSQL DBMS assigns itself. I need the value of that field for the second INSERT and I don't see how to retrieve it inside the SQL method.
something along : SELECT curval('name_of_sequence'); if your fields is of type SERIAL then postgresql has automatically created a sequence for you, which name is probably something like : seq_id_tablename hth. Jerome Alet