Re: No return from trigger function

From: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: No return from trigger function
Date: 2009-04-08 20:19:18
Message-ID: 45335.216.185.71.24.1239221958.squirrel@webmail.harte-lyne.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, April 8, 2009 16:06, Tom Lane wrote:
> "James B. Byrne" <byrnejb(at)harte-lyne(dot)ca> writes:
>> I just need another set of eyes to see whatever it is that I am
>> overlooking.
>
> The RETURN is inside the EXCEPTION clause.
>
> You really need two BEGINs here, one for the outer function body and
> one for the exception block around the INSERT.
>
> regards, tom lane
>

So, something like:

CREATE OR REPLACE FUNCTION hll_pg_fn_ident_insert()
RETURNS TRIGGER AS $pg_fn$
-- ROW AFTER TRIGGER
-- trigger passes identifier_type and _description
-- received as ARGV[0] and ARGV[1]
BEGIN
BEGIN
INSERT INTO identifiers(...
...
EXCEPTION
WHEN ....
END;
RETURN NULL:
END;

--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:ByrneJB(at)Harte-Lyne(dot)ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2009-04-08 20:31:33 Re: Are there performance advantages in storing bulky field in separate table?
Previous Message hubert depesz lubaczewski 2009-04-08 20:16:55 Re: No return from trigger function