How to jump out of loops in Oracle stored procedures

Source: Internet
Author: User

How to jump out of loops in Oracle stored procedures Blog Category:
    • Oracle
Oracle records the use of exit and return
Exit to jump out of the loop
Loop
IF V_KBP is NULL then
EXIT;
END IF;
End Loop;

Return jump out of stored procedure
Loop
IF V_KBP is NULL then
Return
END IF;
End Loop;

Jump out of Loop once
Oracle 11g has provided continue;
Oracle 10g and below, use Goto instead, for example

Sql> set serveroutput on;
Sql> Declare
2 begin
3 for I in 1..10 loop
4 if mod (i,2) =0 Then
5 goto Next;
6 End If;
7 Dbms_output.put_line (i);
8 <<next>>
9 null;
Ten end Loop;
one end;
12/
Note the null after the:<<next>> tag, but the statement must be followed by an execution statement after the Goto label

How to jump out of loops in Oracle stored procedures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.