Re: Does INSERT inserts always at the end ?

From: florence(dot)henry(at)obspm(dot)fr (Florence HENRY)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Does INSERT inserts always at the end ?
Date: 2004-05-25 08:15:14
Message-ID: f24d453f.0405250015.18cc998e@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

jseymour(at)LinxNet(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Postgresql 2004-05-25 11:21:25 FW: Majordomo results: subscribe pgsql-general
Previous Message Kaare Rasmussen 2004-05-25 07:37:07 Re: Ingres to be released as open source