X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED67A14B2806 for ; Mon, 9 Aug 2004 14:14:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93130-09 for ; Mon, 9 Aug 2004 17:14:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5AAF414B27FC for ; Mon, 9 Aug 2004 14:14:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i79HE3oB016662; Mon, 9 Aug 2004 13:14:03 -0400 (EDT) To: Vlad Dimitriu Cc: pgsql-sql@postgresql.org Subject: Re: Exception handling from trigger In-reply-to: <4117AA90.9080704@base.ro> References: <4117AA90.9080704@base.ro> Comments: In-reply-to Vlad Dimitriu message dated "Mon, 09 Aug 2004 19:47:12 +0300" Date: Mon, 09 Aug 2004 13:14:03 -0400 Message-ID: <16661.1092071643@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/64 X-Sequence-Number: 18561 Vlad Dimitriu writes: > I would like to handle the exceptions that a database returns. For example, > if a "mycolumn" column is defined as varchar(64), I'd like to catch > if the new.mycolumn is larger than 64 with my own trigger You can't. From a logical perspective this is sensible, because the trigger is handed data already formed into a tuple. If the presented tuple contained a mycolumn value wider than 64 characters then it would not be a legal value of the rowtype (any more than if, say, the column value were an integer and not a varchar at all). What I'd suggest if you want this is to remove the datatype restriction and instead rely on your trigger to enforce the limitation. regards, tom lane