Trouble with exception - Mailing list pgsql-sql

From samantha mahindrakar
Subject Trouble with exception
Date
Msg-id f0c828c40806060729k7de49b2fsfc20e648dff8bb8a@mail.gmail.com
Whole thread Raw
Responses Re: Trouble with exception  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-sql
Hi....
Iam trying to insert records into a table......when an integrity
constarint violation occurs the exception is caught........but i dont
want the whole thing to be rolled back or stopped because of one
exception. The insert statement is as follows:

'INSERT INTO '||imputation_table||'     (SELECT
lane_id,speed,volume,occupancy,quality,measurement_start,measurement_end,effective_date,expiration_date
FROM '||partitionname||'     WHERE lane_id IN(select lane_id from lane_info where inactive is
null )AND (volume=255 OR speed=255 OR occupancy=255 OR occupancy>=100
OR volume>52 OR volume<0 OR speed>120 OR speed<0)     AND date_part(''hour'', measurement_start) between 5 and 23
ANDdate_part(''day'',measurement_start)='||theDate||')';
 

EXCEPTION  WHEN integrity_constraint_violation THENRAISE NOTICE 'Imputation for lane at time  has been already
imputed';

Is there a way i can just skip the record that causes the violation
and insert the rest of the records into the table???



Thanks
Sam


pgsql-sql by date:

Previous
From: Holm Tiffe
Date:
Subject: Re: Problems with a Query between 7.3 and 8.2
Next
From: Steve Midgley
Date:
Subject: Re: design resource