Re: Does INSERT inserts always at the end ? - Mailing list pgsql-general

From florence.henry@obspm.fr (Florence HENRY)
Subject Re: Does INSERT inserts always at the end ?
Date
Msg-id f24d453f.0405250015.18cc998e@posting.google.com
Whole thread Raw
In response to Does INSERT inserts always at the end ?  (florence.henry@obspm.fr (Florence HENRY))
Responses Re: Does INSERT inserts always at the end ?  (Martijn van Oosterhout <kleptog@svana.org>)
List 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 by date:

Previous
From: "Dane Dwyer"
Date:
Subject: vacuumdb: vacuuming of database "xxx" failed: ERROR: failed to re-find parent key in "pg_class_relname_nsp_index"
Next
From: "angshumitra ghosh"
Date:
Subject: Backend crash