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

From Aaron J. Seigo
Subject Re: [HACKERS] Get OID of just inserted record
Date
Msg-id 99110211160101.28375@stilborne
Whole thread Raw
In response to Re: [HACKERS] Get OID of just inserted record  ("Andrij Korud" <akorud@polynet.lviv.ua>)
Responses Re: [HACKERS] Get OID of just inserted record
Re: [HACKERS] Get OID of just inserted record
List 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


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] file descriptors leak?
Next
From: Lamar Owen
Date:
Subject: Re: [HACKERS] 6.5.3 is ready