pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mattis Jiderhamn <mattias@expertsystem.se>
Cc: pgsql-sql@postgresql.org
Subject: Re: Cast '' (blank) to null date
Date: Fri, 20 Jul 2001 11:58:25 -0400
Message-ID: <3749.995644705@sss.pgh.pa.us> (raw)
In-Reply-To: <9j8udq$fmo$1@news.tht.net>
References: <9j8udq$fmo$1@news.tht.net>

"Mattis Jiderhamn" <mattias@expertsystem.se> 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



view thread (2+ messages)

Message-ID: <3749.995644705@sss.pgh.pa.us>
Permalink:  ../3749.995644705@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3749.995644705@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mattias@expertsystem.se
  Subject: Re: Cast '' (blank) to null date
  In-Reply-To: <3749.995644705@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox