I have searched unsuccessfully for the answer to this so I hope that one of
you may be able to help me.
I am using the new RETURNING functionality but can't make it work in a
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.
if (SPI_exec("INSERT ....", 0) < 0)
Datum test = SPI_getbinval(SPI_tuptable->vals, SPI_tuptable->tupdesc,
I have used similar code to get values from SELECT without problems. I
assumed that an INSERT RETURNING would place the returned value into the
global SPI_tuptable, but it seems that this isn't the case? If, right after
the SPI_exec, I check SPI_tuptable it is indeed NULL.
I guess my question is then: In a trigger using SPI_exec, how does one get
the RETURNING part of the query?
Thank you for any help you could offer,
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2007-07-07 21:46:42|
|Subject: Re: 8.2 RETURNING functionality in a trigger |
|Previous:||From: Viatcheslav Kalinin||Date: 2007-07-06 16:41:37|
|Subject: Re: distinct doesn't work|