PL/pgSQL中的BREAK语句 [英] BREAK statement in PL/pgSQL
问题描述
如何在PostgreSQL中使用break
语句?我有这样的结构:
How to have the break
statement in PostgreSQL? I have the structure like this:
for()
{
for()
{
if(somecondition)
break;
}
}
据我了解,它应该只中断内部for
循环吗?
As per my understanding it should only break the inner for
loop?
推荐答案
EXIT
终止循环.
CONTINUE
在循环的下一次迭代中继续.
您可以将<<label>>
附加到循环,并将其作为参数添加到每个命令中.然后终止/继续标记为的循环.否则,它涉及到 inner 循环.
RETURN
从函数退出(因此不适用于 DO
声明).
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).
所有这些都适用于PL/pgSQL的过程元素,不是 SQL.
使用这三个示例的代码示例:
All of this applies to procedural elements of PL/pgSQL, not SQL.
Code example using all three:
这篇关于PL/pgSQL中的BREAK语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!