Re: trigger on view returning created serial

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Philipp Kraus <philipp(dot)kraus(at)flashpixx(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: trigger on view returning created serial
Date: 2012-06-12 23:40:39
Message-ID: 1339544439.12295.107.camel@sussancws0025
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2012-06-13 00:51:13 Re: UPDATE Syntax Check
Previous Message Jeff Davis 2012-06-12 23:36:11 Re: Reference with inheritance propagate data