nextval/dbi question
От | harrold@sage.che.pitt.edu |
---|---|
Тема | nextval/dbi question |
Дата | |
Msg-id | Pine.LNX.4.21.0108051648180.4939-100000@sage.che.pitt.edu обсуждение исходный текст |
Ответ на | select vs varchar (Francisco Reyes <lists@natserv.com>) |
Ответы |
Re: nextval/dbi question
|
Список | pgsql-novice |
hey. i'm using dbi in perl to access a table whos primary key is a serialized variable. i want to preform an insert on the table and i want the value of the key associated with that insert. this is what i'm doing: # i get the new value like this: select nextval('testtable_the_key_seq'); #and then i preforme the insert like this: insert into testtable (an_id, timestamp) values (2, 2); what results. say the last value of the sequence is 'n-1' so the select nextval statement above will return 'n' but when i preform the insert the value of testtable.the_key is actually 'n+1'. should i wrap the insert up into a transaction? any help would be most appreciated. i dont know if this is relevent but in perl i'm preparing the statement by using (?,?) and place holders for the (2,2). thanks john
В списке pgsql-novice по дате отправления: