error tolerant inserting of data

From: "Jules Alberts" <jules(dot)alberts(at)arbodienst-limburg(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: error tolerant inserting of data
Date: 2003-03-05 14:17:31
Message-ID: 20030305141807.8A7781CB1A5@koshin.dsl.systemec.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello everybody,

I'm working on a new pg database that will contain all data that's
currently in our old system. The data is already in the db, in tables
with names like import_table1, import_table2 etc., now I have to
transfer them to the real tables. The real tables have some
constraints, like trigger functions to prevent overlapping date-
periods.

I have written pl/pgsql code to do the importing bit, but there is one
big drawback: as soon as anything in a function (or in a FOR ... SELECT
... LOOP) goes wrong, everything is rolled back. Normally this
behaviour would be fine, but not in this situation, because my old data
contains rows sometimes conflicts with the constraints.

What I want is all conflicting rows to be not imported, just plainly be
refused, and let everything that's OK be imported. What is the best way
to do this?

TIA!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-03-05 14:36:35 Re: error tolerant inserting of data
Previous Message Laurent Perez 2003-03-05 14:10:51 bug ? updates and insert crash the backend