Re: Trigger Function return values - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Trigger Function return values
Date
Msg-id 201103221738.19017.adrian.klaver@gmail.com
Whole thread Raw
In response to Trigger Function return values  ("Andy Chambers" <achambers@mcna.net>)
List pgsql-general

On Tuesday, March 22, 2011 3:12:56 pm Andy Chambers wrote:

> Hi,

>

> How is the return value of a trigger function defined in plpgsql used? I

> can't find

> anything in the documentation but some of the examples return NULL, and

> others return

> something like NEW.

>

> It seems that if the return statement is omitted, an error occurs when the

> trigger is

> fired.

From here:

http://www.postgresql.org/docs/9.0/interactive/plpgsql-trigger.html

Row triggers:

"Row-level triggers fired BEFORE can return null to signal the trigger manager to skip the rest of the operation for this row (i.e., subsequent triggers are not fired, and the INSERT/UPDATE/DELETE does not occur for this row). If a nonnull value is returned then the operation proceeds with that row value. Returning a row value different from the original value of NEW alters the row that will be inserted or updated. "

Statement triggers:

"The return value of a row-level trigger fired AFTER or a statement-level trigger fired BEFORE or AFTER is always ignored; it might as well be null. However, any of these types of triggers might still abort the entire operation by raising an error. "

--

Adrian Klaver

adrian.klaver@gmail.com

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Trigger Function return values
Next
From:
Date:
Subject: constraint partition issue