Re: 8.2 RETURNING functionality in a trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Doug Johnson" <metaphaze(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: 8.2 RETURNING functionality in a trigger
Date: 2007-07-07 21:46:42
Message-ID: 12325.1183844802@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Doug Johnson" <metaphaze(at)gmail(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tjibbe 2007-07-08 08:52:37 REVOKE on ALTER USER, DROP USER
Previous Message Doug Johnson 2007-07-07 21:21:10 8.2 RETURNING functionality in a trigger