Re: returning clause on triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vaduvoiu Tiberiu <vaduvoiutibi(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: returning clause on triggers
Date: 2010-11-12 16:12:16
Message-ID: 11075.1289578336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Vaduvoiu Tiberiu <vaduvoiutibi(at)yahoo(dot)com> writes:
> I have a table that has a "on before insert" rule, which looks like this:
> "On insert to XX do instead insert into YY values(a,b,c) returning a,b,c."
> It works ok, but the returning clause does not actually return these values when I perform an insert query. So basically if I run a "insert into XX..." query, I get no results back, even though the query executes correctly. This could be because the original query does not have the returning clause, only the trigger has.

Well, yeah. The RETURNING clause in the rule just instructs the system
how to transform INSERT RETURNING queries that are supposed to be
rewritten by the rule. It does not mean "force INSERTs to act like they
have RETURNING even when they don't". That would be a very surprising
behavior that would break most client code.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stodge 2010-11-12 19:50:33 ODBC Cursor inserting records appears to lock the database
Previous Message Vaduvoiu Tiberiu 2010-11-12 15:39:18 returning clause on triggers