Skip site navigation (1) Skip section navigation (2)

Trouble with exception

From: "samantha mahindrakar" <sam(dot)mahindrakar(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trouble with exception
Date: 2008-06-06 14:29:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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
		 AND date_part(''day'',measurement_start)='||theDate||')';

EXCEPTION  WHEN integrity_constraint_violation THEN
	RAISE 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???



pgsql-sql by date

Next:From: Steve MidgleyDate: 2008-06-06 14:57:11
Subject: Re: design resource
Previous:From: Holm TiffeDate: 2008-06-05 17:46:48
Subject: Re: Problems with a Query between 7.3 and 8.2

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group