Re: About how to use "exception when ??? then " - Mailing list pgsql-sql

From Richard Huxton
Subject Re: About how to use "exception when ??? then "
Date
Msg-id 4419B616.2040105@archonet.com
Whole thread Raw
In response to About how to use "exception when ??? then "  (Emi Lu <emilu@encs.concordia.ca>)
Responses Re: About how to use "exception when ??? then "
List pgsql-sql
Emi Lu wrote:
>       exception
>          WHEN  ???   THEN

> The place where I have ???, what I should put there please?
> 
> e.g.,
> 1. WHEN sqlcode = '02000' THEN
> 2. WHEN no_data then

no_data

See ch 35.7.5. "Trapping Errors" for an example

> 3.  other ways?
> 
>  From the 8.0 docs, I am not be able to find Constant values of all 
> error codes.
> http://www.postgresql.org/docs/8.0/static/errcodes-appendix.html
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.)"

I don't know if any have changed in 8.1, but there is a list of the 
codes in that version of the docs. http://www.postgresql.org/docs/8.1/static/errcodes-appendix.html
--   Richard Huxton  Archonet Ltd


pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: executing external command
Next
From: Emi Lu
Date:
Subject: Re: About how to use "exception when ??? then "