[HACKERS] How to get OID from INSERT in PL/PGSQL?

Поиск
Список
Период
Сортировка
От Ed Loehr
Тема [HACKERS] How to get OID from INSERT in PL/PGSQL?
Дата
Msg-id 3841864F.F4642DC6@austin.rr.com
обсуждение исходный текст
Ответы Re: [HACKERS] How to get OID from INSERT in PL/PGSQL?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] How to get OID from INSERT in PL/PGSQL?  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
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.

If so, can someone please demonstrate how this is done?

If not, can someone in the know definitely state the means by which it
is currently possible to do this?

Why would someone want to do this?  Because it is the only way I know
of to definitively retrieve a newly-generated serial value for use as
the primary/foreign key (a *very* common RDBMS practice).  Other
suggested approaches to skinning this cat are welcome.  If PL/PGSQL
can't do this, it seems rather severely limited in its usefulness for
non-trivial databases.  In this post,


http://www.postgresql.org/mhonarc/pgsql-general/1998-07/msg00203.html

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

This question has been asked in one form or another in a number of
posts in pgsql-general and pgsql-sql, but without any definitive
answers.  I have experimented, scoured the mailing list archives, the
postgresql PL/pgSQL documentation, and deja.com to no avail, thus my
post here.

So, is it possible with PL/pgSQL?  How?  Thanks in advance...

Cheers,
Ed



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Development installation fails
Следующее
От: "Oliver Elphick"
Дата:
Сообщение: UNION not allowed in sub-selects?