pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCast '' (blank) to null date
2+ messages / 2 participants
[nested] [flat]
* Cast '' (blank) to null date
@ 2001-07-20 09:44 Mattis Jiderhamn <mattias@expertsystem.se>
2001-07-20 15:58 ` Re: Cast '' (blank) to null date Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Mattis Jiderhamn @ 2001-07-20 09:44 UTC (permalink / raw)
To: pgsql-sql
Hi there everyone.
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 believe my ploblem is that I don't know the type of blank (''), and
therefore do not know what to cast from.
It seems it is not unknown.
Any other suggestions?
Thanks,
Mattias Jiderhamn
mattias@expertsystem.se
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Cast '' (blank) to null date
2001-07-20 09:44 Cast '' (blank) to null date Mattis Jiderhamn <mattias@expertsystem.se>
@ 2001-07-20 15:58 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2001-07-20 15:58 UTC (permalink / raw)
To: Mattis Jiderhamn <mattias@expertsystem.se>; +Cc: pgsql-sql
"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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-07-20 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-20 09:44 Cast '' (blank) to null date Mattis Jiderhamn <mattias@expertsystem.se>
2001-07-20 15:58 ` Tom Lane <tgl@sss.pgh.pa.us>
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