Re: [HACKERS] Get OID of just inserted record

From: Peter Eisentraut <e99re41(at)DoCS(dot)UU(dot)SE>
To: "Aaron J(dot) Seigo" <aaron(at)gtv(dot)ca>
Cc: Andrij Korud <akorud(at)polynet(dot)lviv(dot)ua>, Jan Wieck <wieck(at)debis(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Get OID of just inserted record
Date: 1999-11-02 18:48:41
Message-ID: Pine.GSO.4.02A.9911021943140.19808-100000@Hermelin.DoCS.UU.SE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2 Nov 1999, Aaron J. Seigo wrote:

> would it be possible to add a RETURN clause to INSERT? e.g.
>
> INSERT into t1 VALUES('xxx') RETURN oid;
>
> i could see where this would be useful in many different circumstances.. i
> know this isn't standards compliant, but would be very cool =) i know that with
> triggers, you have access to the current/old/new information, could this be
> harnessed to supply a RETURN facility?

I'm not sure what I'm missing here:

=> insert into foo values (4, 'aaa');
INSERT 7998067 1

This line is generated by libpq's PQcmdStatus(). You can also just get the
oid part by using PQoidStatus(). Is that what you wanted or do you need a
wrapper or binding for a certain environment?

-Peter

--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-11-02 19:14:01 Re: [HACKERS] Get OID of just inserted record
Previous Message Aaron J. Seigo 1999-11-02 18:47:34 Fwd: Re: fs/etx2/file.c question from postgres developers...