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 114FBD6857 for ; Wed, 23 Nov 2005 07:44:00 -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 65182-07 for ; Wed, 23 Nov 2005 11:44:03 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 14209DB7DA for ; Wed, 23 Nov 2005 07:43:57 -0400 (AST) Received: from iracema.dnscenter.com.br (iracema3.dnscenter.com.br [67.15.81.2]) by svr2.postgresql.org (Postfix) with ESMTP id 13205F0BC9 for ; Wed, 23 Nov 2005 11:44:00 +0000 (GMT) Received: from cpanel by iracema.dnscenter.com.br with local (Exim 4.52) id 1Eet2X-00001z-8s for pgsql-sql@postgresql.org; Wed, 23 Nov 2005 08:43:53 -0300 Received: from 200.158.186.105 ([200.158.186.105]) by www.presserv.org (Horde MIME library) with HTTP; Wed, 23 Nov 2005 08:43:53 -0300 Message-ID: <20051123084353.8ga6nrpx43gg8408@www.presserv.org> Date: Wed, 23 Nov 2005 08:43:53 -0300 From: lucas@presserv.org To: pgsql-sql@postgresql.org Subject: Default on update MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iracema.dnscenter.com.br X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - presserv.org X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.877 required=5 tests=[NO_REAL_NAME=0.55, RCVD_IN_NJABL_PROXY=0.327] X-Spam-Score: 0.877 X-Spam-Level: X-Archive-Number: 200511/218 X-Sequence-Number: 23469 Hi. Is there a way to create "default" constraint on UPDATE query. It's becouse I have a bool field that may NOT support NULL value, but the Front-End calls null for FALSE values. I was thinking something like: create table table1 ( id serial primary key, bv bool default false not null ); I would want to replace "bv" values with FALSE when insert/update NULL value for this field. 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 NEW.bv=FALSE; END IF; END; ' language 'plpgsql'; CREATE TRIGGER TG_table1_check BEFORE UPDATE on table1 for each row execute procedure tg_table1_check(); Other question: I have a lot of triggers in my db system, I have table that has 5/6 triggers, many triggers are simple (like the tg_table1_check), any are complex... Is it a problem??? My tests are with few regs and run fine. Where can I read more about triggers and performance? Thanks for all. --- Lucas Vendramin