pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Emi Lu <emilu@encs.concordia.ca>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: About how to use "exception when ??? then "
Date: Thu, 16 Mar 2006 14:44:53 -0500
Message-ID: <4419C035.7000008@encs.concordia.ca> (raw)
In-Reply-To: <4419B616.2040105@archonet.com>
References: <4419AB1A.3070805@encs.concordia.ca>
	<4419B616.2040105@archonet.com>


> <snip> From the page:
> "The PL/pgSQL condition name for each error code is the same as the 
> phrase shown in the table, with underscores substituted for spaces. 
> For example, code 22012, DIVISION BY ZERO, has condition name 
> DIVISION_BY_ZERO. Condition names can be written in either upper or 
> lower case.


> (Note that PL/pgSQL does not recognize warning, as opposed to error, 
> condition names; those are classes 00, 01, and 02.)"


That means pl/pgsql will not recognize error codes under classes 00, 01, 
02.

Is there a way, I can output error code?
exception
  when ... then
  when others then
   raise notice '%, %', SQLSTATE, SQLERRM;

But it seems that SQLERRM and SQLSTATE did not work for me. By the way, 
I am using postgresql 8.0.1.

Thanks a lot,
Ying

> <snip>





view thread (7+ messages)  latest in thread

Message-ID: <4419C035.7000008@encs.concordia.ca>
Permalink:  ../4419C035.7000008@encs.concordia.ca/
Also on:    postgresql.org/message-id/4419C035.7000008@encs.concordia.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: emilu@encs.concordia.ca, dev@archonet.com
  Subject: Re: About how to use "exception when ??? then "
  In-Reply-To: <4419C035.7000008@encs.concordia.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox