Insert NULL for '' - Mailing list pgsql-general

From Daniel Gehrke
Subject Insert NULL for ''
Date
Msg-id 000d01c3319f$9055d090$05011fac@neustac005
Whole thread Raw
Responses Re: Insert NULL for ''
Re: Insert NULL for ''
List pgsql-general
Hello,

I am porting an application from MS SQL 7.0 that dynamically creates
statements.
I have a table with a date field. Now I would like postgresql to insert NULL
when I insert '':

insert into foo (bar) values ('');

So in this case I want postgresql to insert NULL instead of giving the error
message "ERROR:  Bad date external representation '' "

I know, that the error message is correct and that "insert into foo (bar)
values (NULL)" would be the correct way. But unfortunately I cannot change
the application to do so, therefore my question is:
Is there any possibility to get postgresql to insert NULL when I do "insert
into foo (bar) values ('')?

Daniel Gehrke


pgsql-general by date:

Previous
From: Martin Marques
Date:
Subject: Re: Postgres performance comments from a MySQL user
Next
From: Christoph Haller
Date:
Subject: Re: query plan and parenthesis