Thread: Getting exception information (SQLERRM, SQLSTATE, etc.)

Getting exception information (SQLERRM, SQLSTATE, etc.)

From
"Lance Arlaus"
Date:

Is there a way to get information on an exception inside an exception block?

I’ve looked on the net and saw some postings regarding a patch for 8.0 that may or may not be integrated into the main release at this point.

I’m currently running 8.0.3, writing a function using the plpgsql language and have tried several options, albeit unsuccessfully.

I want to enable something like the following:

 

BEGIN

            [ STATEMENT THAT THROWS AN EXCEPTION]

EXCEPTION WHEN OTHERS THEN

            RAISE NOTICE ‘exception (code=%): %’, SQLCODE, SQLERRM;

            [ DO SOMETHING ELSE]

END;

 

Thanks,

Lance

Re: Getting exception information (SQLERRM, SQLSTATE, etc.)

From
Tom Lane
Date:
"Lance Arlaus" <lance.nospam.1@codeberet.com> writes:
> Is there a way to get information on an exception inside an exception block?

Not in 8.0.  We have integrated SQLSTATE and SQLERRM for 8.1.

            regards, tom lane