On Jan 9, 2004, at 1:11 PM, azwa@nc.com.my wrote:
> how do we run the COPY command from file which has several null
> columns in each field.
> thanks.
>
> example :
>
> dwnc=# copy biosadm.custinv_temp
> dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ;
> ERROR: copy: line 1, Missing data for column "subsidiary"
Just like you specify the delimiter, you need to specify the value for
NULL. For example, if your *.txt file has a line with a "missing" value
(such as the space between 'bar' and 'foofoo')
foo bar foofoo barbar
I usually use 'NULL' as NULL, so the line would be
foo bar NULL foofoo barbar
then use the COPY command with NULL AS 'NULL'
Check out the following link for detailed info on the COPY command:
<http://www.postgresql.org/docs/current/static/sql-copy.html>
HTH
Michael Glaesemann
grzm myrealbox com