Re: Insert NULL for '' - Mailing list pgsql-general

From Mike Mascari
Subject Re: Insert NULL for ''
Date
Msg-id 3EEB37E4.8010103@mascari.com
Whole thread Raw
In response to Re: Insert NULL for ''  (Tino Wildenhain <tino@wildenhain.de>)
List pgsql-general
Tino Wildenhain wrote:

> Hi,
>
>
> Mike Mascari wrote:
> ...
>
>> What would be really neat is the ability of CREATE CAST to override
>> the default implementation and at the same time let the override call
>> the "base" implementation, if necessary.
>
> This is already possible: you just have to define your own
> type which would behave like a date for all operations
> but not for text2yourdate, which would then accept ''
> for null as well.
>
> Might be a little bit work, buts perfectly doable.

Sure, but client applications, such as ODBC, which understand the SQL
data types won't be able to handle your custom type. And Daniel would
have to modify the schema to use a custom type. I was thinking that
the casting function is called by the database when it gets a string
literal as a text type, but, from reading Tom's response, I guess that
is not the case. If it did, it would have been nice for Daniel to just
override the casting function to handle the NULL mapping of '' for the
DATE datatype. It would also be useful in allowing for customization
of text mappings for the number types as well.

Mike Mascari
mascarm@mascari.com


pgsql-general by date:

Previous
From: Tino Wildenhain
Date:
Subject: Re: Insert NULL for ''
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Index not being used in MAX function (7.2.3)