简体   繁体   中英

BREAK statement in PL/pgSQL

How to have the break statement in PostgreSQL? I have the structure like this:

for()
 {
 for()
 {
  if(somecondition)
  break;
 }
}

As per my understanding it should only break the inner for loop?

There is no BREAK in PL/pgSQL .

EXIT terminates the loop.
CONTINUE continues at the next iteration of the loop.
You can attach a <<label>> to loops and add it as parameter to each of these commands. Then you terminate / continue the labeled loop. Else, it concerns the inner loop.
RETURN exits from the function (so not applicable in a DO statement).

All of this applies to procedural elements of PL/pgSQL, not SQL.
Code example using all three:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM