From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | PostgreSQL pg-general List <pgsql-general(at)postgresql(dot)org> |
Cc: | Ken Winter <ken(at)sunward(dot)org> |
Subject: | Re: Converting empty input strings to Nulls |
Date: | 2008-05-31 18:52:34 |
Message-ID: | 48419E72.3090603@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Pavel Stehule wrote:
> Hello
>
> 2008/5/31 Ken Winter <ken(at)sunward(dot)org>:
>> ... but an empty string still evokes the error even before this function is
>> triggered.
>>
>> Is there a way to convert empty strings to Nulls before the error is evoked?
>>
> no - it's not possible. And some "magic" fix in triggers is bad style.
The rule system may be able to handle this transformation (using insert
rules or an updateable view). Getting it to work could be a bit arcane,
though, and having never really delved into the rule system I can't be
of much help.
See:
http://www.postgresql.com.cn/docs/8.3/static/rules.html
http://www.postgresql.com.cn/docs/8.3/static/sql-createrule.html
http://wiki.postgresql.org/wiki/Updatable_views
http://wiki.postgresql.org/wiki/Introduction_to_PostgreSQL_Rules_-_Making_entries_which_can't_be_altered
Personally, though, if at all possible I'd fix the broken client
application. "" is NOT NULL . If you don't fix it, consider at least
clearly documenting the wacky behaviour and if possible applying it only
to an updatable view rather than the base table.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2008-05-31 18:54:25 | Re: Converting empty input strings to Nulls |
Previous Message | Pavel Stehule | 2008-05-31 18:35:29 | Re: Converting empty input strings to Nulls |