Re: 8.2 RETURNING functionality in a trigger - Mailing list pgsql-novice

From Tom Lane
Subject Re: 8.2 RETURNING functionality in a trigger
Date
Msg-id 12325.1183844802@sss.pgh.pa.us
Whole thread Raw
In response to 8.2 RETURNING functionality in a trigger  ("Doug Johnson" <metaphaze@gmail.com>)
List pgsql-novice
"Doug Johnson" <metaphaze@gmail.com> writes:
> In psql I can run a query like this:
>     INSERT INTO foo(col1, col2, col3) VALUES (1, 2, 3) RETURNING col1;
> and I get col1 back from the insert.

> Now, when I do that in a C trigger via SPI_exec the SPI_exec succeeds, but I
> can't figure out how to access the RETURNING part.

Works for me; I suspect the problem is in some part of your code that
you didn't show us.  Is it really just a plain INSERT/RETURNING (no
possible interference from rules, say)?  Are you really only testing the
SPI_exec result code for negative (maybe you forgot to allow
SPI_OK_INSERT_RETURNING as a valid result)?

            regards, tom lane

pgsql-novice by date:

Previous
From: "Doug Johnson"
Date:
Subject: 8.2 RETURNING functionality in a trigger
Next
From: Tjibbe
Date:
Subject: REVOKE on ALTER USER, DROP USER