From: fastjack@... (Martin Maciaszek) Date: 2002-02-06T17:21:41+09:00 Subject: Re: some dbi questions (probably postres specific) In article <20020205094852.D65533@ninja1.internal>, Sean Chittenden wrote: [snip] >> >> now I insert some data into the table with the following code: >> aConnection.execute "insert into test_table (name, phone) values >> ('foo', '42');" > >id = dbh.select_one("SELECT currval('test_table_id_seq')")[0] > >This is what all DBI's do under the hood. After an insert into a >table with an incrementing sequence, the connection will honnor >curval(seq_name) which will return the value of the increment after >the insert into the row. Just make sure that your user has read >access to the sequence. > But what happens when in the mean time somebody else inserts another record into the database? I get the wrong sequence. How can I prevent this? Cheers Martin