Re: trigger on view returning created serial - Mailing list pgsql-general

From Jeff Davis
Subject Re: trigger on view returning created serial
Date
Msg-id 1339544439.12295.107.camel@sussancws0025
Whole thread Raw
In response to trigger on view returning created serial  (Philipp Kraus <philipp.kraus@flashpixx.de>)
List pgsql-general
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-RETURNING....html

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


pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Reference with inheritance propagate data
Next
From: David Johnston
Date:
Subject: Re: UPDATE Syntax Check