Re: [HACKERS] How to get OID from INSERT in PL/PGSQL? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [HACKERS] How to get OID from INSERT in PL/PGSQL?
Date
Msg-id Pine.LNX.4.20.9911292245430.658-100000@localhost.localdomain
Whole thread Raw
In response to [HACKERS] How to get OID from INSERT in PL/PGSQL?  (Ed Loehr <ELOEHR@austin.rr.com>)
List pgsql-hackers
On 1999-11-28, Ed Loehr mentioned:

> Is it possible to programmatically retrieve the OID of a just-inserted
> record in a PL/PGSQL function?  Apparently, it is not currently
> possible in psql, but I'm hoping C programming is not required for
> this.

For what it's worth, psql will be able to do this in the next release. It
will look like this:

=> insert into foo values (...);
=> insert into bar values (:LastOid, ...);

which is even marginally SQL compliant as I understand. If you are daring
you can get the current snapshot and try it, but I wouldn't sign my life
away on it quite yet.

> Bruce Momjian says its possible for things using libpq "directly" to
> retrieve the oid.  Does PL/PGSQL use libpq directly?

Everything(?) uses libpq more or less directly. It's just a matter of
interfacing your applicaton to the OidStatus function. The above psql does
just that.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Tricky query, tricky response
Next
From: Peter Eisentraut
Date:
Subject: Portability (was Re: [HACKERS] Development installation fails)