Re: No return from trigger function - Mailing list pgsql-general

From James B. Byrne
Subject Re: No return from trigger function
Date
Msg-id 45335.216.185.71.24.1239221958.squirrel@webmail.harte-lyne.ca
Whole thread Raw
In response to Re: No return from trigger function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, April 8, 2009 16:06, Tom Lane wrote:
> "James B. Byrne" <byrnejb@harte-lyne.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@Harte-Lyne.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


pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: No return from trigger function
Next
From: Tom Lane
Date:
Subject: Re: some external sql not working in psql