Skip site navigation (1) Skip section navigation (2)

returning clause on triggers

From: Vaduvoiu Tiberiu <vaduvoiutibi(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: returning clause on triggers
Date: 2010-11-12 15:39:18
Message-ID: 497758.89208.qm@web51303.mail.re2.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
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.

Long story short, the query should basically do:
"Insert into XX(...) values(...) returning [what the trigger retunrs]. Is that possible? Because this would basically replace the "mysql_insert_id" functions that I was using.

Thanks in advance.



      

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2010-11-12 16:12:16
Subject: Re: returning clause on triggers
Previous:From: Jason Tan Boon TeckDate: 2010-11-12 10:00:26
Subject: Re: Update a table from another table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group