Re: [HACKERS] Get OID of just inserted record

From: "Aaron J(dot) Seigo" <aaron(at)gtv(dot)ca>
To: "Andrij Korud" <akorud(at)polynet(dot)lviv(dot)ua>, "Jan Wieck" <wieck(at)debis(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Get OID of just inserted record
Date: 1999-11-02 18:13:40
Message-ID: 99110211160101.28375@stilborne
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi...

> My question is:
> "CREATE TABLE t1 (word text)"
> "INSERT INTO t1 VALUES('xxx')" (using SPI_execp)
>
> So, is there any way to obtain OID of word 'xxx' just after insertion
> without doing "SELECT oid FROM t1 WHERE word='xxx'"?

i've been watching this thread and it has caused this thought rumble forth:

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?

just a thought.. probably ignorable.

--
Aaron J. Seigo
Sys Admin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 1999-11-02 18:13:42 Re: [HACKERS] file descriptors leak?
Previous Message Marcin Grondecki 1999-11-02 17:49:35 Re: [GENERAL] users in Postgresql