X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE35B476083; Thu, 24 Apr 2003 15:06:51 -0400 (EDT) Received: from snoopy.oit.edu (snoopy.OIT.EDU [140.211.135.12]) by postgresql.org (Postfix) with ESMTP id BAE93475F16; Thu, 24 Apr 2003 15:06:50 -0400 (EDT) Received: from cvc.net (purvine-141-62.oit.edu [140.211.141.62]) by snoopy.oit.edu (8.12.9/8.12.9/OIT-4.0) with ESMTP id h3OJ6mpX002126; Thu, 24 Apr 2003 12:06:48 -0700 Message-ID: <3EA836AF.8060704@cvc.net> Date: Thu, 24 Apr 2003 12:10:39 -0700 From: Dennis Gearon Reply-To: gearond@cvc.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, ru MIME-Version: 1.0 To: Robert Treat Cc: Josh Berkus , "pgsql-general@postgresql.org" , pgsql-sql@postgresql.org Subject: Re: [SQL] rewriting values with before trigger References: <1051201544.4753.522.camel@camel> <200304240939.54070.josh@agliodbs.com> <1051209495.7747.544.camel@camel> In-Reply-To: <1051209495.7747.544.camel@camel> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/1258 X-Sequence-Number: 41323 How about putting the data validity and conversion routine in ONE trigger? OR, deliberately name your triggers with alphanumerical prefixes that forces them to fire in a certain order, and making the trigger that does the conversion fire first? I have no idea how the transport of a value of '' happens in the parser if it's expecing a NULL/INT value, if it would even make it to the trigger stage . Robert Treat wrote: > On Thu, 2003-04-24 at 12:39, Josh Berkus wrote: > >>Robert, >> >> >>>Is there anyway to do be able to change the '' into NULL before data >>>validity is checked with a trigger? >> >>What about using a RULE instead? >> > > > RULE's follow this same behavior, erroring out if the data is not a > valid timestamp. (At least I've not been able to write a rule that > doesn't follow this) In fact you actually can't create the rule if you > have a where clause that isn't a proper matching datatype. > > I seem to recall a solution for folks who need '' to represent 0 in int > fields was to use triggers or rules, but I guess that really isn't > possible :-( > > Robert Treat > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html >