RE: [HACKERS] Error in the date field (with NULL value...).Thanks!

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Maurizio Ortolan" <crix98__(at)tin(dot)it>, <pgsql-general(at)postgresql(dot)org>
Subject: RE: [HACKERS] Error in the date field (with NULL value...).Thanks!
Date: 2001-04-02 01:31:43
Message-ID: ECEHIKNFIMMECLEBJFIGAECNCAAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-bugs pgsql-general pgsql-hackers pgsql-patches pgsql-ports pgsql-sql

Just do a search-replace on your source file and replace all occurrences of
'' with NULL.

Chris

-----Original Message-----
From: pgsql-hackers-owner(at)postgresql(dot)org
[mailto:pgsql-hackers-owner(at)postgresql(dot)org]On Behalf Of Maurizio Ortolan
Sent: Thursday, 29 March 2001 12:51 PM
To: pgsql-hackers(at)postgresql(dot)org; pgsql-sql(at)postgresql(dot)org;
pgsql-general(at)postgresql(dot)org; pgsql-ports(at)postgresql(dot)org;
pgsql-admin(at)postgresql(dot)org; pgsql-bugs(at)postgresql(dot)org;
pgsql-patches(at)postgresql(dot)org
Subject: [HACKERS] Error in the date field (with NULL value...).Thanks!

Subject: Importing data from Informix to PostgreSQL.
Error in the date field (WITH NULL value)

Hello!
I'll try to explain my little problem. Well, I have this table

create table mytable
( codice char(16) not null,
dt_inizio date,
dt_fine date,
tipo_operazione char(1),
causa_operazione integer
);

ok!

I find out that pgsql:

In my example '' is the NULL value exported from Informix... ! (an ASCII
file)

INFORMIX PostgreSQL
char(16) '' ------> blank
string (I think it's ok! )
char(1) '' ------> blank
string (I think it's ok)
integer '' ------> 0 (is
it an error? )
date '' ------> ERROR! Bad date
external representation ''

>> select * from mytable ;

codice | dt_inizio | dt_fine |
tipo_operazione | causa_operazione

ABCEDEFFFFFFFFF |
2001-03-28 | | | 0
XXXYYYAAA23C957Y |
2001-03-28 | | | 0

clinica=# insert into mytable values ( '','03/28/2001', '' , '' , '' );
ERROR: Bad date external representation '' ^^^

PostgreSQL doesn't want '' as an input of a date with NULL value:
it's necessary to use this kind of insert:

>> insert into mytable values ( '','03/28/2001',null,'','');
^^^^^^

Now there is a new line in the table:

|
2001-03-28 | | | 0

My question:
How can I resolv my problem? I have a big data file to import where
in the 2nd date field there is '' instead of null ....

How can I "binds" PostgreSQL to consider '' as null ?

Many thanks for any suggestions!

CIAO!
MAURIZIO

*******************************************
** Happy surfing on THE NET !! **
** Ciao by **
** C R I X 98 **
*******************************************
AntiSpam: rimuovere il trattino basso
dall'indirizzo per scrivermi...
(delete the underscore from the e-mail address to reply)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Grant 2001-04-02 04:29:16 Mirroring, Clustering, Hot swapable.
Previous Message Yasuo Ohgaki 2001-04-01 09:05:24 libpq bug? (I guess not)

Browse pgsql-bugs by date

  From Date Subject
Next Message Lonnie Cumberland 2001-04-02 13:13:24 PostgreSQL tcp connection
Previous Message Hauke Joachim Zuehl 2001-04-01 23:46:20 Clients do not compile with X11 includes under C++

Browse pgsql-general by date

  From Date Subject
Next Message Murakami 2001-04-02 01:34:58 pg_ctl stop returns error
Previous Message Doug McNaught 2001-04-02 00:18:45 Re: Ok, why isn't it using *this* index?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-04-02 03:09:45 Re: Re: Call for platforms
Previous Message Roberto Mello 2001-04-01 22:13:18 Re: PL/SQL and null

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-04-02 03:23:54 Re: patch for minor Win32 makefile bug
Previous Message Fred Yankowski 2001-04-01 22:05:55 Re: patch for minor Win32 makefile bug

Browse pgsql-ports by date

  From Date Subject
Next Message Tom Lane 2001-04-02 03:23:54 Re: patch for minor Win32 makefile bug
Previous Message Fred Yankowski 2001-04-01 22:05:55 Re: patch for minor Win32 makefile bug

Browse pgsql-sql by date

  From Date Subject
Next Message J.Fernando Moyano 2001-04-02 02:44:00 very very slow .....
Previous Message Tom Lane 2001-04-01 19:34:55 Re: ON DELETE rule