pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: emilu@encs.concordia.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: About how to use "exception when ??? then "
Date: Fri, 17 Mar 2006 08:11:50 +0000
Message-ID: <441A6F46.5080609@archonet.com> (raw)
In-Reply-To: <4419C035.7000008@encs.concordia.ca>
References: <4419AB1A.3070805@encs.concordia.ca>
	<4419B616.2040105@archonet.com>
	<4419C035.7000008@encs.concordia.ca>

Emi Lu wrote:
> 
>> <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.

Correct - they are informational rather than errors. I'm not sure what 
it would mean to trap "successful completion" for example.

> 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.

http://www.postgresql.org/docs/8.1/static/release-8-1.html

See section E.4.3.9 - they were defined in 8.1

-- 
   Richard Huxton
   Archonet Ltd



view thread (7+ messages)

Message-ID: <441A6F46.5080609@archonet.com>
Permalink:  ../441A6F46.5080609@archonet.com/
Also on:    postgresql.org/message-id/441A6F46.5080609@archonet.com

 · 

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: dev@archonet.com, emilu@encs.concordia.ca
  Subject: Re: About how to use "exception when ??? then "
  In-Reply-To: <441A6F46.5080609@archonet.com>

* 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