Re: exception handling and CONTINUE

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(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:13:05
Message-ID: 162867790807080613k1ff32e6fx49613a78356bdb93@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

no, you can use CONTINUE only in loop. When you wont ignore exception,
just do nothing

For example, the following two fragments of code are equivalent:

BEGIN
y := x / 0;
EXCEPTION
WHEN division_by_zero THEN
NULL; -- ignore the error
END;

BEGIN
y := x / 0;
EXCEPTION
WHEN division_by_zero THEN -- ignore the error
END;

http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html

Regards
Pavel Stehule

2008/7/8 Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com>:
> 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;
>
> I get an error saying I can't use CONTINUE outside of a loop. Is there a way
> around this ?
>
> regards
> mk

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sabin Coanda 2008-07-08 16:37:41 Re: how to control the execution plan ?
Previous Message Alvaro Herrera 2008-07-08 13:06:29 Re: exception handling and CONTINUE