Getting exception information (SQLERRM, SQLSTATE, etc.) - Mailing list pgsql-novice

From Lance Arlaus
Subject Getting exception information (SQLERRM, SQLSTATE, etc.)
Date
Msg-id 008601c59d37$ed9c4210$6401a8c0@LanceLaptop
Whole thread Raw
Responses Re: Getting exception information (SQLERRM, SQLSTATE, etc.)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice

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

pgsql-novice by date:

Previous
From: Sean Davis
Date:
Subject: Re: Suspend Referential Integrity?
Next
From: James Nobles
Date:
Subject: loading data for newb