Re: Separating data sets in a table

From: Andreas Tille <tillea(at)rki(dot)de>
To: PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Separating data sets in a table
Date: 2002-08-26 06:26:03
Message-ID: Pine.LNX.4.44.0208260820060.27720-100000@wr-linux02.rki.ivbb.bund.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, 25 Aug 2002, Mark Stosberg wrote:

> Thanks for the clarification. Here's an idea about how to solve your
> problem. As you are importing your data, instead of doing it all at
> once, try import it a row at a time into a table that has the RI turned
> on. Check each insert to see if it's successful. It if it's not
> successful, then insert that row into a table that /doesn't/ have RI
> (maybe "import_failures"),
> perhaps also including the error that Postgres returned. (This may be
> stored in $DBH::errstr). Then when you are done, you can look in the
> import_failures for a report of which rows need some assistance. If you
> need every row to succeed that's imported into the production table, you
> can do all this inside of a transaction, and roll it back if any of the
> inserts fail. [ thinks for a moment. ] Of course, that would normally
> rollback your inserts into import_failures too, so perhaps you can use a
> second database connection to make sure those always happen.
>
> I hope that helps. Perhaps thinking in terms of "row-at-a-time
> processing" will help you solve your problem.
Well for sure this might be an option but as I said I receive the data
in the dump format apropriate to use "COPY <tablemane> FROM <file>". Would
you really like to suggest me to split those data sets into single lines?
Moreover I'm not sure about how to catch the error messages of failed
COPY statements.

I've thought that including all data and handling them afterwards would
be agood idea and it is just my lack of SQL knowledge which prevents
me from finding a clever solution to sort the stuff out.

Kind regards

Andreas.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Wheeler 2002-08-26 07:05:20 ANNOUNCE: Bricolage 1.3.3
Previous Message Bruce Momjian 2002-08-26 00:31:12 Re: LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?