[GENERAL] trigger on view returning created serial

2012-06-12 Thread Philipp Kraus
Hello,

I have created a view and on this view a trigger, which is called on an insert 
command on the view.
Within the trigger I run an insert on a table and one of the table fields uses 
a serial sequence, that
creates values. If I run in the trigger after the insert a return NEW, the 
field (id) which should
be set by the serial on the table is 0, so how can I get the new created serial 
on the insert command
within the trigger function?

Thanks

Phil
-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] trigger on view returning created serial

2012-06-12 Thread Jeff Davis
On Tue, 2012-06-12 at 22:35 +0200, Philipp Kraus wrote:
 Hello,
 
 I have created a view and on this view a trigger, which is called on an 
 insert command on the view.
 Within the trigger I run an insert on a table and one of the table fields 
 uses a serial sequence, that
 creates values. If I run in the trigger after the insert a return NEW, the 
 field (id) which should
 be set by the serial on the table is 0, so how can I get the new created 
 serial on the insert command
 within the trigger function?

It's hard for me to tell exactly what problem you're describing, but it
sounds similar to the one solved here:

http://people.planetpostgresql.org/dfetter/index.php?/archives/66-VIEW-triggers-RETURNINGhtml

If I misunderstood, please be more descriptive about what you are trying
to do, what code you wrote, and what went wrong.

Regards,
Jeff Davis


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general