Re: Does INSERT inserts always at the end ?

Поиск
Список
Период
Сортировка
От florence.henry@obspm.fr (Florence HENRY)
Тема Re: Does INSERT inserts always at the end ?
Дата
Msg-id f24d453f.0405250015.18cc998e@posting.google.com
обсуждение исходный текст
Ответ на Does INSERT inserts always at the end ?  (florence.henry@obspm.fr (Florence HENRY))
Ответы Re: Does INSERT inserts always at the end ?
Список pgsql-general
jseymour@LinxNet.com (Jim Seymour) wrote :

> Define what you mean by "with a script."  If you've a db handle open
> with, say, Perl's DBI, you could simply do a select on currval() for
> the sequence and get it.  This is immune to other transactions.

Indeed, I'm using Perl's DBI. currval does exactly what I want. Thanks to
all who pointed it to me.

Before I could read your messages, I made a workaround that worked nice also,
but could you tell me if it would always work ?

It uses the "oid" number. I've read that it used to be unique, but within
the same session, I can assume that it is always growing, can't I ?

INSERT into A VALUES (DEFAULT, "toto");

INSERT into B VALUES (
   (SELECT id FROM A WHERE oid = SELECT ( max(oid) from A)),
   "toto");

--
Florence HENRY
florence point henry arobasse obspm point fr

В списке pgsql-general по дате отправления: