Re: Getting OID after Insert - Mailing list pgsql-general

From Tom Lane
Subject Re: Getting OID after Insert
Date
Msg-id 24807.1003428104@sss.pgh.pa.us
Whole thread Raw
In response to Getting OID after Insert  (Bruce Cota <bruce@vivi.com>)
List pgsql-general
Bruce Cota <bruce@vivi.com> writes:
> Is there a way, in SQL, to access the oid of the row created
> by an immediately preceding insert statement?

If you are writing a psql script, recent psql versions maintain
a LASTOID variable:

regression=# insert into int4_tbl default values;
INSERT 3357467 1
regression=# select :LASTOID;
 ?column?
----------
  3357467
(1 row)

regression=#

            regards, tom lane

pgsql-general by date:

Previous
From: Keary Suska
Date:
Subject: Re: Accessing PostgreSQL through Apache and PHP4 on
Next
From: Jason Earl
Date:
Subject: Re: newbie authentication/automated backup (pg_dumpall) questions