Re: exception handling and CONTINUE

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: exception handling and CONTINUE
Date: 2008-07-08 13:06:29
Message-ID: 20080708130629.GA4095@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2008-07-08 13:13:05 Re: exception handling and CONTINUE
Previous Message Marcin Krawczyk 2008-07-08 12:24:57 exception handling and CONTINUE