X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64429475E9D; Thu, 24 Apr 2003 12:25:40 -0400 (EDT) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id A8F71474E42; Thu, 24 Apr 2003 12:25:39 -0400 (EDT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h3OH7iF0025760; Thu, 24 Apr 2003 13:07:44 -0400 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h3OGPix07965; Thu, 24 Apr 2003 12:25:44 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 2YCPWH03; Thu, 24 Apr 2003 12:25:43 -0400 Subject: rewriting values with before trigger From: Robert Treat To: "pgsql-general@postgresql.org" , pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 24 Apr 2003 12:25:44 -0400 Message-Id: <1051201544.4753.522.camel@camel> Mime-Version: 1.0 X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_XIMIAN 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/1244 X-Sequence-Number: 41309 Is there a way to use triggers to rewrite data before determining if the data for that field is valid? postgres=# create table foo ( postgres(# bar timestamptz postgres(# ); CREATE postgres=# create or replace function test() returns opaque as ' postgres'# begin postgres'# NEW.bar := NULL; postgres'# return NEW; postgres'# end; postgres'# ' language 'plpgsql'; CREATE postgres=# create trigger baz before insert on foo for each row execute procedure test(); CREATE postgres=# insert into foo values (now()); INSERT 411474706 1 postgres=# select * from foo; bar ----- (1 row) postgres=# insert into foo values (''); ERROR: Bad timestamp external representation '' Is there anyway to do be able to change the '' into NULL before data validity is checked with a trigger? (FWIW this is 7.2, if this would actually work in 7.3 please lmk) TIA, Robert Treat