【PL/SQL】Control structure

IF:
IF condition THEN statements;
[ELSIF condition THEN statements;]
[ELSE statements;]
END IF;

Case expression
appraisal := CASE v_grade
appraisal := CASE
CASE v_mngid

For:
Do not reference the counter as the target of an assignment.
Neither loop bound should be NULL.

FOR counter IN [REVERSE] lower_bound…upper_bound LOOP
statement1; statement2; …
END LOOP;

FOR i IN 3…3 LOOP
statement1;
END LOOP;

Basic loop:
LOOP
statement1;

EXIT [WHEN condition];
END LOOP;

WHEN expression1 THEN result1 WHEN expression2 THEN result2 …
WHEN expressionN THEN resultN
[ELSE resultN+1]
END;
/

While:
WHILE condition LOOP (true)
statement1;
statement2;

END LOOP;

Nested loop:
You can nest loops to multiple levels.
Use labels to distinguish between blocks and loops. <<outer_loop>>
Exit the outer loop with the EXIT statement that references the label

BEGIN
<<Outer_loop>>
LOOP
v_counter := v_counter+1;
EXIT WHEN v_counter>10;
<<Inner_loop>>
LOOP …
EXIT Outer_loop WHEN total_done = ‘YES’; – Leave both loops
EXIT WHEN inner_done = ‘YES’;
– Leave inner loop only

END LOOP Inner_loop;

END LOOP Outer_loop;
END;
/

Continue:
-control loop iterations
-filter data inside a loop body before the main processing begins
-transfer control within a loop back to a new iteration or to leave the loop.
–  Adds the functionality to begin the next loop iteration
–  Provides programmers with the ability to transfer control to the next iteration of a loop
–  Uses parallel structure and semantics to the EXITstatement
• Benefits
–  Eases the programming process
–  May see a small performance improvement over the previous programming workarounds to simulate the CONTINUE statement

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值