Explicit NULL for no INTEGER data?

Started by Rich Shepardabout 15 years ago5 messagesgeneral
Jump to latest
#1Rich Shepard
rshepard@appl-ecosys.com

I have a data file I want to copy into a table. The column name and
attribute is:

depth_seal INTEGER

one of the rows in the .csv file I want to bring into the table has no value
for this column, but there is no explicit NULL in the text file. When I try
to copy the file psql complains:

ERROR: invalid input syntax for integer: ""
CONTEXT: COPY water_well, line 1, column depth_seal: ""

Do I need an explicit NULL in that column?

Rich

#2Rich Shepard
rshepard@appl-ecosys.com
In reply to: Rich Shepard (#1)
Re: Explicit NULL for no INTEGER data? -- Update

On Fri, 18 Feb 2011, Rich Shepard wrote:

Do I need an explicit NULL in that column?

Update: Placing NULL or a blank produces the same error.

How should I represent no value for an integer column in a .csv file?

Rich

#3Mike Christensen
mike@kitchenpc.com
In reply to: Rich Shepard (#2)
Re: Explicit NULL for no INTEGER data? -- Update

Judging from:

http://www.postgresql.org/docs/8.1/static/sql-copy.html

It looks like you have to specify your own NULL string with the NULL
AS parameter of the COPY command.

Show quoted text

On Fri, Feb 18, 2011 at 3:12 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Fri, 18 Feb 2011, Rich Shepard wrote:

Do I need an explicit NULL in that column?

 Update: Placing NULL or a blank produces the same error.

 How should I represent no value for an integer column in a .csv file?

Rich

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Rich Shepard
rshepard@appl-ecosys.com
In reply to: Mike Christensen (#3)
Re: Explicit NULL for no INTEGER data? -- Update

On Fri, 18 Feb 2011, Mike Christensen wrote:

It looks like you have to specify your own NULL string with the NULL
AS parameter of the COPY command.

Mike,

I completely missed that option when I've read the copy page. My
apologies!

Rich

#5Mike Christensen
mike@kitchenpc.com
In reply to: Rich Shepard (#4)
Re: Explicit NULL for no INTEGER data? -- Update

It looks like you have to specify your own NULL string with the NULL
AS parameter of the COPY command.

Mike,

 I completely missed that option when I've read the copy page. My
apologies!

Rich

Awesome, I'm the one usually asking easy questions on this mailing
list so I'm just glad I could answer one for once!