CAST(null as date)... - Mailing list pgsql-general

From Ian Harding
Subject CAST(null as date)...
Date
Msg-id sd0f4e20.098@mail.tpchd.org
Whole thread Raw
Responses Re: CAST(null as date)...  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
I tried to create a function to return the string 'null' (without quotes, of course...) if the input was a zero length
string,so I could use it in casting arguments to another function such as: 

select myfunction(cast(nullifzls($maybeemptyvar) as date), cast(....));

However I have this dilemma.  The return type from the nullifzls function is text.  Text blows up the cast.  Is there
anyway to make this work, or should I do something else?   

plantest=# select cast(null as date);
 ?column?
----------

(1 row)

plantest=# select nullifzls('');
 nullifzls
---------------
 null
(1 row)

plantest=# select cast(nullifzls('') as date);
ERROR:  Bad date external representation 'null'


plantest=# select cast(cast('null' as text) as date);
ERROR:  Bad date external representation 'null'

Thanks...

Ian



pgsql-general by date:

Previous
From: John Gray
Date:
Subject: Re: point-in-polygon error
Next
From: Stephan Szabo
Date:
Subject: Re: Highly obscure and erratic