On Wed, 2009-04-08 at 16:06 -0400, 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.
Many people find it surprising that PL/pgSQL allows this occur. It would
be good to have a TODO item relating to improved checking of PL/pgSQL
functions to avoid runtime errors.
--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support