Ignore when using COPY FROM

Lists: pgsql-general
From: mkennedy(at)hssinc(dot)com (Matthew Kennedy)
To: pgsql-general(at)postgresql(dot)org
Subject: Ignore when using COPY FROM
Date: 2000-08-29 14:15:07
Message-ID: 39ABC56B.1A3F7F6A@opushealthcare.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I have a ton of data in a text delimited file from an old legacy system.
When uploading it into postgres, I'd do something like this:

COPY stuff FROM 'stuff.txt' USING DELIMITERS = '|';

The problem is some of the rows in stuff.txt may not conform to the
stuff table attributes (duplicate keys, for example). The command above
terminates with no change to the table stuff when it encounters an error
in stuff.txt. Is there a way to have postgres ignore erroneous fields
but keep information about which fields weren't processed. I believe
Oracle has some support for this through an IGNORE clause.


From: "Adam Lang" <aalang(at)rutgersinsurance(dot)com>
To: "Matthew Kennedy" <mkennedy(at)hssinc(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Ignore when using COPY FROM
Date: 2000-08-29 15:24:34
Message-ID: 00d701c011cd$3ce0b0a0$330a0a0a@Adam
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Well, you could always make a table that has no constraints on duplicates
and COPY TO that one. Then, make a query that inserts the data into your
production table that handles the duplicates.

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "Matthew Kennedy" <mkennedy(at)hssinc(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, August 29, 2000 10:15 AM
Subject: [GENERAL] Ignore when using COPY FROM

> I have a ton of data in a text delimited file from an old legacy system.
> When uploading it into postgres, I'd do something like this:
>
> COPY stuff FROM 'stuff.txt' USING DELIMITERS = '|';
>
> The problem is some of the rows in stuff.txt may not conform to the
> stuff table attributes (duplicate keys, for example). The command above
> terminates with no change to the table stuff when it encounters an error
> in stuff.txt. Is there a way to have postgres ignore erroneous fields
> but keep information about which fields weren't processed. I believe
> Oracle has some support for this through an IGNORE clause.


From: Alfred Perlstein <bright(at)wintelcom(dot)net>
To: Adam Lang <aalang(at)rutgersinsurance(dot)com>
Cc: Matthew Kennedy <mkennedy(at)hssinc(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Ignore when using COPY FROM
Date: 2000-08-29 15:50:41
Message-ID: 20000829085041.W18862@fw.wintelcom.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> From: "Matthew Kennedy" <mkennedy(at)hssinc(dot)com>
> > I have a ton of data in a text delimited file from an old legacy system.
> > When uploading it into postgres, I'd do something like this:
> >
> > COPY stuff FROM 'stuff.txt' USING DELIMITERS = '|';
> >
> > The problem is some of the rows in stuff.txt may not conform to the
> > stuff table attributes (duplicate keys, for example). The command above
> > terminates with no change to the table stuff when it encounters an error
> > in stuff.txt. Is there a way to have postgres ignore erroneous fields
> > but keep information about which fields weren't processed. I believe
> > Oracle has some support for this through an IGNORE clause.

* Adam Lang <aalang(at)rutgersinsurance(dot)com> [000829 08:29] wrote:
> Well, you could always make a table that has no constraints on duplicates
> and COPY TO that one. Then, make a query that inserts the data into your
> production table that handles the duplicates.

Actually, last I checked COPY INTO actually checks the RULE system, so
I'm pretty sure one can setup a rule to check for violated constraints
and 'INSTEAD DO NOTHING'. :-)

-Alfred


From: Fredrick Bartlett <palmtreefrb(at)earthlink(dot)net>
To: Matthew Kennedy <mkennedy(at)hssinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Ignore when using COPY FROM
Date: 2000-08-30 16:37:00
Message-ID: 39AD382C.B6151D72@earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Yes, I have same problem. This functionality is "almost" standard,
and
found on other RDBMS. How do new features get added to the todo list's.
Where can I view the current todo list?

Fredrick

Matthew Kennedy wrote:

> I have a ton of data in a text delimited file from an old legacy system.
> When uploading it into postgres, I'd do something like this:
>
> COPY stuff FROM 'stuff.txt' USING DELIMITERS = '|';
>
> The problem is some of the rows in stuff.txt may not conform to the
> stuff table attributes (duplicate keys, for example). The command above
> terminates with no change to the table stuff when it encounters an error
> in stuff.txt. Is there a way to have postgres ignore erroneous fields
> but keep information about which fields weren't processed. I believe
> Oracle has some support for this through an IGNORE clause.


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Fredrick Bartlett <palmtreefrb(at)earthlink(dot)net>
Cc: Matthew Kennedy <mkennedy(at)hssinc(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Ignore when using COPY FROM
Date: 2000-10-16 16:10:33
Message-ID: 200010161610.MAA09176@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Added to TODO:

* Allow COPY to specify column names

> Yes, I have same problem. This functionality is "almost" standard,
> and
> found on other RDBMS. How do new features get added to the todo list's.
> Where can I view the current todo list?
>
> Fredrick
>
> Matthew Kennedy wrote:
>
> > I have a ton of data in a text delimited file from an old legacy system.
> > When uploading it into postgres, I'd do something like this:
> >
> > COPY stuff FROM 'stuff.txt' USING DELIMITERS = '|';
> >
> > The problem is some of the rows in stuff.txt may not conform to the
> > stuff table attributes (duplicate keys, for example). The command above
> > terminates with no change to the table stuff when it encounters an error
> > in stuff.txt. Is there a way to have postgres ignore erroneous fields
> > but keep information about which fields weren't processed. I believe
> > Oracle has some support for this through an IGNORE clause.
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026