Insert NULL for ''

From: "Daniel Gehrke" <dgehrke(at)neusta(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Insert NULL for ''
Date: 2003-06-13 11:33:08
Message-ID: 000d01c3319f$9055d090$05011fac@neustac005
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Poslusny 2003-06-13 11:41:58 Re: query plan and parenthesis
Previous Message Christoph Haller 2003-06-13 11:23:18 Re: query plan and parenthesis