Re: breaking out of a loop in plpgsql

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Celia McInnis <celia(at)drmath(dot)ca>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: breaking out of a loop in plpgsql
Date: 2005-06-09 17:51:10
Message-ID: 1118339470.27924.11.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, 2005-06-09 at 12:35 -0500, Celia McInnis wrote:
> How do I break out of a loop in plpgsql?

>From the plpgsql docs:

EXIT [ label ] [ WHEN expression ];

If no label is given, the innermost loop is terminated and the
statement following END LOOP is executed next. If label is
given, it must be the label of the current or some outer level
of nested loop or block. Then the named loop or block is
terminated and control continues with the statement after the
loop's/block's corresponding END.

If WHEN is present, loop exit occurs only if the specified
condition is true, otherwise control passes to the statement
after EXIT.

EXIT can be used to cause early exit from all types of loops; it
is not limited to use with unconditional loops.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Daniel T. Staal 2005-06-09 18:56:47 Function debugging question
Previous Message Celia McInnis 2005-06-09 17:35:24 breaking out of a loop in plpgsql