Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6KFwia69756 for ; Fri, 20 Jul 2001 11:58:44 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f6KFwQC03752; Fri, 20 Jul 2001 11:58:26 -0400 (EDT) To: "Mattis Jiderhamn" cc: pgsql-sql@postgresql.org Subject: Re: Cast '' (blank) to null date In-reply-to: <9j8udq$fmo$1@news.tht.net> References: <9j8udq$fmo$1@news.tht.net> Comments: In-reply-to "Mattis Jiderhamn" message dated "Fri, 20 Jul 2001 11:44:08 +0200" Date: Fri, 20 Jul 2001 11:58:25 -0400 Message-ID: <3749.995644705@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200107/282 X-Sequence-Number: 4080 "Mattis Jiderhamn" writes: > I'm trying to create a trigger so that, if I try to insert blank, that is > '', into a date field it will be converted to null so that I don't get > ERROR: Bad date external representation '' I don't think it's possible to do that with a trigger. By the time the trigger is called, the proposed row has already been formed, so any input data conversion errors that might occur will already have occurred. You'll have to code the substitution on the application side, or perhaps in the SQL query with a CASE expression. regards, tom lane