X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87D9DDB965 for ; Wed, 23 Nov 2005 10:08:01 -0400 (AST) 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 85457-04 for ; Wed, 23 Nov 2005 14:08:04 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id EB08BDB900 for ; Wed, 23 Nov 2005 10:07:58 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id AE2B04130C6; Wed, 23 Nov 2005 14:07:53 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E426015EA4; Wed, 23 Nov 2005 14:08:02 +0000 (GMT) Message-ID: <438477C3.6080208@archonet.com> Date: Wed, 23 Nov 2005 14:08:03 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en MIME-Version: 1.0 To: lucas@presserv.org Cc: pgsql-sql@postgresql.org Subject: Re: Default on update References: <20051123084353.8ga6nrpx43gg8408@www.presserv.org> <43845F23.60204@archonet.com> <20051123104134.3be3vpyxlc00kko4@www.presserv.org> <20051123105626.fon1t82f0ctcgogw@www.presserv.org> In-Reply-To: <20051123105626.fon1t82f0ctcgogw@www.presserv.org> 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 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/222 X-Sequence-Number: 23473 lucas@presserv.org wrote: >>> I would want to replace "bv" values with FALSE when insert/update >>> NULL value for >>> this field. >> >> You could do this by having the application insert to a view with a >> rule that replaces null bv values before redirecting to the base table. > > Is more functional to create a Rule instead of a trigger? It's different - you can think of a rule as a kind of macro, rewriting the query the application provides. Make sure you read the manuals carefully to be sure you understand how they work though. >>> Or need I create a TRIGGER that check it and replace the itens??? >>> CREATE or REPLACE function TG_table1_check RETURNS trigger as ' >>> BEGIN >>> IF nullvalue(NEW.bv) THEN >> >> >> IF NEW.bv IS NULL THEN >> > What is the difference between nullvalue() and IS NULL??? "IS NULL" is a standard SQL expression. -- Richard Huxton Archonet Ltd