"Michael Paesold" <[EMAIL PROTECTED]> writes:
> In a PL/pgSQL function I want to insert into a table and get the OID back.
> That usually works with
> GET DIAGNOSTICS last_oid = RESULT_OID;
> right after the insert statement.
> But if the table that I insert to has a rule (or perhaps a trigger?) that
> updates another table, the RESULT_OID after the insert will be 0 (zero).
As of CVS tip, this example produces the results I believe you want:
regression=# SELECT pltestfunc(10);
NOTICE: RESULT_OID: 282229
NOTICE: RESULT_OID: 282230
NOTICE: RESULT_OID: 282231
NOTICE: RESULT_OID: 282232
NOTICE: RESULT_OID: 282233
NOTICE: RESULT_OID: 282234
NOTICE: RESULT_OID: 282235
NOTICE: RESULT_OID: 282236
NOTICE: RESULT_OID: 282237
NOTICE: RESULT_OID: 282238
pltestfunc
------------
t
(1 row)
regression=# SELECT * FROM pltest;
id | t
----+------
1 | test
2 | test
3 | test
4 | test
5 | test
6 | test
7 | test
8 | test
9 | test
10 | test
(10 rows)
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/users-lounge/docs/faq.html