Getting exception information (SQLERRM, SQLSTATE, etc.)

From: "Lance Arlaus" <lance(dot)nospam(dot)1(at)codeberet(dot)com>
To: "PostgreSQL Novice Mailing List" <pgsql-novice(at)postgresql(dot)org>
Subject: Getting exception information (SQLERRM, SQLSTATE, etc.)
Date: 2005-08-09 23:13:17
Message-ID: 008601c59d37$ed9c4210$6401a8c0@LanceLaptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message James Nobles 2005-08-09 23:58:52 loading data for newb
Previous Message Michael Fuhr 2005-08-09 13:31:06 Re: Suspend Referential Integrity?