Re: exception handling and CONTINUE - Mailing list pgsql-sql

From Alvaro Herrera
Subject Re: exception handling and CONTINUE
Date
Msg-id 20080708130629.GA4095@alvh.no-ip.org
Whole thread Raw
In response to exception handling and CONTINUE  ("Marcin Krawczyk" <jankes.mk@gmail.com>)
Responses Re: exception handling and CONTINUE
List pgsql-sql
Marcin Krawczyk escribió:
> Hi all. Can anyone tell me if there's a way to use CONTINUE clause outside
> the loop ?
> An example :
> 
> FOR a IN SELECT * FROM xxx
> LOOP
> 
> INSERT INTO yyy VALUES (a.***, ..)
> 
> END LOOP;
> 
> EXCEPTION WHEN unique_violation THEN CONTINUE;

Try something like this:

for a in select * from xxx
loop begin   insert into yyy values (...) exception when unique_violation then   null;    -- noop, just for clarity
end;
end loop;

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-sql by date:

Previous
From: "Marcin Krawczyk"
Date:
Subject: exception handling and CONTINUE
Next
From: "Pavel Stehule"
Date:
Subject: Re: exception handling and CONTINUE