X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E81DD9DCBAD for ; Thu, 16 Mar 2006 15:29:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85698-07-2 for ; Thu, 16 Mar 2006 15:29:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by postgresql.org (Postfix) with ESMTP id 685059DCAD8 for ; Thu, 16 Mar 2006 15:29:50 -0400 (AST) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by ptb-relay03.plus.net with esmtp (Exim) id 1FJyAQ-0007xH-8T; Thu, 16 Mar 2006 19:29:50 +0000 Received: from mainbox.archonet.com (unknown [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 8BB1040DDA2; Thu, 16 Mar 2006 19:01:43 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 3C9A8FF04; Thu, 16 Mar 2006 19:01:43 +0000 (GMT) Message-ID: <4419B616.2040105@archonet.com> Date: Thu, 16 Mar 2006 19:01:42 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: emilu@encs.concordia.ca Cc: pgsql-sql@postgresql.org Subject: Re: About how to use "exception when ??? then " References: <4419AB1A.3070805@encs.concordia.ca> In-Reply-To: <4419AB1A.3070805@encs.concordia.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] X-Spam-Score: 0.125 X-Spam-Level: X-Archive-Number: 200603/239 X-Sequence-Number: 24585 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