dbTalk Databases Forums  

Re: Copy From problem

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Re: Copy From problem in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Manuel Sugawara
 
Posts: n/a

Default Re: Copy From problem - 05-24-2004 , 01:27 PM






Eduardo Vázquez Rodríguez <evazquez (AT) insys-corp (DOT) com.mx> writes:

Quote:
My question is how can I insert a null value into the field
email,and that "copy from" continue copying the next lines?
Use \N to represent the null value, for instance (following your
notation (\t) to represent the tab char).

Jessie Rodriguez (\t) West Beach (\t) \N

Regards,
Manuel.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
  #2  
Old   
Nabil Sayegh
 
Posts: n/a

Default Re: Copy From problem - 05-24-2004 , 01:31 PM






Eduardo Vázquez Rodríguez wrote:
Quote:
Hi I try to "copy from" a plain text file that looks someting like this:

John Red (\t) Garden Grove (\t) jwayne (AT) garden (DOT) com
Jessie Rodriguez (\t) West Beach
Jane Harrison (\t) Malibu (\t) jharrison (AT) malibu (DOT) com

Deliberately I missed the email info in the second line, I try to copy into
a table that has the following structure:

CREATE TABLE public."Example"
(
"Name" varchar(30),
"Adress" varchar(60),
"Email" varchar(30),
) WITHOUT OIDS;

My question is how can I insert a null value into the field email,and that
"copy from" continue copying the next lines?
In recent versions you can specify the columns to import.

COPY "Example" ("Name", "Adress") FROM ...

or somethign like that.

BTW: I suggest not using uppercase table/field-names.
It's too much hazzle always having to quote table and field names

HTH
--
e-Trolley Sayegh & John, Nabil Sayegh
Tel.: 0700 etrolley /// 0700 38765539
Fax.: +49 69 8299381-8
PGP : http://www.e-trolley.de

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #3  
Old   
Oliver Elphick
 
Posts: n/a

Default Re: Copy from problem - 05-30-2004 , 12:39 AM



On Mon, 2004-05-24 at 18:54, Eduardo Vázquez Rodríguez wrote:
Quote:
When I issue the following command
copy public."Example" from '/home/postgres/abc.txt';

The following error appears

ERROR: missing data for column "Email"
CONTEXT: COPY Prueba, line 2: "Jessie Rodriguez Santa Anna "

My question is how can I insert a null value into the field email,and that
copy from continue copying the next lines?
Null values are represented by \N (or by some other string specified in
the COPY command - see its documentation).

--
Oliver Elphick olly (AT) lfix (DOT) co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Do all things without murmurings and disputings;
that ye may be blameless and harmless, the sons of
God, without rebuke, in the midst of a crooked and
perverse nation, among whom ye shine as lights in the
world." Philippians 2:14,15


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.