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 44A809DCB94 for ; Fri, 17 Mar 2006 04:26:14 -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 11898-10 for ; Fri, 17 Mar 2006 04:26:14 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pih-relay04.plus.net (pih-relay04.plus.net [212.159.14.131]) by postgresql.org (Postfix) with ESMTP id 9B7C29DCA1F for ; Fri, 17 Mar 2006 04:26:11 -0400 (AST) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by pih-relay04.plus.net with esmtp (Exim) id 1FKAHk-00081d-0C; Fri, 17 Mar 2006 08:26:12 +0000 Received: from mainbox.archonet.com (unknown [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id B9F8C40C28F; Fri, 17 Mar 2006 08:11:51 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 2BB1BFF04; Fri, 17 Mar 2006 08:11:51 +0000 (GMT) Message-ID: <441A6F46.5080609@archonet.com> Date: Fri, 17 Mar 2006 08:11:50 +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> <4419B616.2040105@archonet.com> <4419C035.7000008@encs.concordia.ca> In-Reply-To: <4419C035.7000008@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/245 X-Sequence-Number: 24591 Emi Lu wrote: > >> 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