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

From hubert depesz lubaczewski
Subject Re: No return from trigger function
Date
Msg-id 20090408201655.GA29224@depesz.com
Whole thread Raw
In response to Re: No return from trigger function  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
List pgsql-general
On Wed, Apr 08, 2009 at 04:13:58PM -0400, James B. Byrne wrote:
> Does this mean that the example given on pg. 798 of the manual is in
> error, or have I misread it?
>          BEGIN
>          EXCEPTION
>              WHEN UNIQUE_VIOLATION THEN
>                  -- do nothing
>          END;

please notice that the BEGIN.... EXCEPTION ... END; are withing main
function BEGIN END.
so it has to be like this:

create function x() returns ... as $$
declare
begin
   whatever;
   begin
     do something
     exception
   end;
   whatever;
end;
$$ language plpgsql;

notice 2 pairs of begin/end.

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

pgsql-general by date:

Previous
From: "James B. Byrne"
Date:
Subject: Re: No return from trigger function
Next
From: "James B. Byrne"
Date:
Subject: Re: No return from trigger function