PL/SQL Process Control statements

Source: Internet
Author: User

PL/SQL Process Control statements
Describes the Process Control statements for PL/SQL, including the following three classes:
Control statement: IF statement
Loop statement: Loop statement, exit statement
Sequential statement: Goto statement, NULL statement
①if statements
IF < Boolean expressions > Then
PL/SQL and statements;
elsif< other Boolean expressions > Then
other statements;
elsif< other Boolean expressions > Then
other statements;
ELSE
other statements;
END IF;

Example:
Declare
     v_emp_name employees.last_name%type;
     v_emp_sal Employees.salary%type;
     v_emp_sal_level varchar2 (20);
Begin
     select Last_name,salary into v_emp_name,v_emp_sal from employees where employee_ id = 150;
     
     if (v_emp_sal >= 10000) then v_emp_sal_level: = ' Salary >= 10000 ';
     elsif (v_emp_sal >=) then v_emp_sal_level: = ' 5000<= salary < 10000 ';
     Else V_emp_sal_level: = ' salary < 5000 ';
     End If;
     
     dbms_output.put_line (v_emp_name| | ', ' | | v_emp_sal| | ', ' | | V_emp_sal_level);
End;

②case-expression
Case Selector
When Expression1 then RESULT1
When Expression2 then RESULT2
When Expressionn then RESULTN
[ELSE resultn+1]
END;

PL/SQL Process Control statements

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.