PL/SQL flow control statements-condition structure, cyclic structure

Source: Internet
Author: User
Tags case statement

I. IF-THEN statement

The IF-THEN statement is the simplest IF statement.

Syntax:

 condition  ;

Example:

 :    v_score    ;
II. IF-THEN-ELSE statement

Compared with the IF-THEN statement, the IF-THEN-ELSE statement provides program exceptions when the conditions are not met.

Syntax:

 condition  ;

Example:

 :    v_score    ;

 

3. IF-THEN-ELSIF statement

This statement is used when multiple different conditions exist. Note that it is ELSIF, not ELSEIF.

Syntax:

 condition1  ;

Example:

 :    v_score      ;

 

Iv. CASE statements

The CASE statement is the control statement structure introduced after Oracle 9i.

Syntax:

 value1  value2  valuen  ;

Example:

 :      dbms_output.put_line(   dbms_output.put_line(   dbms_output.put_line(   dbms_output.put_line(   dbms_output.put_line(   dbms_output.put_line(   dbms_output.put_line( dbms_output.put_line( ;

 

1. LOOP

LOOP is the simplest LOOP. Use the EXIT statement to EXIT the loop.

Syntax:

 LOOP;

Example:

 :  v_num v_num        ;

 

2. WHILE-LOOP

When a WHILE-LOOP is executed, it first determines whether the LOOP condition is TRUE. When the condition is TRUE, it begins to execute the statements in the LOOP body.

Syntax:

 LOOP;

Example:

 :    v_num v_num;

 

3. FOR-LOOP

Compared with the WHILE-LOOP, the FOR-LOOP can clearly know the number of cycles and determine the LOOP range.

Syntax:

 loop_count   LOOP;

Example:

   i  ..;

Related Article

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.