Re: [HACKERS] Get OID of just inserted record - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [HACKERS] Get OID of just inserted record
Date
Msg-id Pine.LNX.4.20.9911022225200.356-100000@peter-e.yi.org
Whole thread Raw
In response to Re: [HACKERS] Get OID of just inserted record  ("Aaron J. Seigo" <aaron@gtv.ca>)
List pgsql-hackers
On Nov 2, Aaron J. Seigo mentioned:

> > => 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
> 
> this assumes that one is using libpq.. it would be nice to have access to this
> from psql or anywhere for that matter.. and not just oids.. but, say for

You can access it right there :) How exactly do you wish to access it in
psql though? (I'm writing around in psql at the moment, so I might
actually implement it!)

> instance, default values in tables that are generated dynamically... etc

Well, now you're saying "I want all this complex data from the database
but I don't want to use SELECT". That does make much sense. The point of
defaults is that you don't need to worry about them. If you need to read
back a record right after you insert it, perhaps you should rethink your
application. Admittedly, I know of several interfaces that make this sort
of thing a royal pain, but you can't get everything for free.

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



pgsql-hackers by date:

Previous
From: "Aaron J. Seigo"
Date:
Subject: Re: [HACKERS] Get OID of just inserted record
Next
From: Dimitri
Date:
Subject: Re: PostgreSQL vs Mysql comparison