× PL/SQL - Overview PL/SQL - Basic Syntax PL/SQL - Data Types PL/SQL - Variables PL/SQL - Constants and Literals PL/SQL - Operators PL/SQL - Conditions PL/SQL -ifelse PL/SQL -elsif PL/SQL -nestedif PL/SQL -Case PL/SQL -Searched Case PL/SQL -Basic Loop PL/SQL -For Loop PL/SQL -While Loop PL/SQL - Strings PL/SQL - Arrays PL/SQL - Procedures PL/SQL - Functions PL/SQL - Cursors PL/SQL - Records PL/SQL - Exceptions PL/SQL - Triggers PL/SQL - Packages PL/SQL - Collections PL/SQL - Transactions PL/SQL - Date & Time PL/SQL - DBMS Output PL/SQL - Object Oriented
  • iconPLSQL Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

PL/SQL - Control Statements

PL/SQL - Control Statements
Control Statements are used to ramdom execution of the program .In PLSQL lamguage these are classified into following types.

1.Conditional Statements
2.Looping Statements
3.Unconditional Statements
Conditional Statements
Conditional statements are used check the condition whether it is true or false.
In PLSQL language these opeatrs are classified into following types.

1.IF - THEN statement
2.IF-THEN-ELSE statement
3.IF-THEN-ELSIF statement
4.nested IF-THEN-ELSE
5.Case statement
6.Searched CASE statement

IF - THEN statement
'if- then' is a keyword in PLSQL language .Which is used to execute one block of statements by negleting some other statements.
if(Condition) then
end if;
In the above syntax 'if' condition is true the statements of 'if' block is execute.'if' the condition is false program terminated.
Example #1
   a number(2) := 10; 
   IF( a < 20 ) THEN 
      dbms_output.put_line('a is less than 20' ); 
   END IF; 
   dbms_output.put_line('value of a is : ' || a); 

Example #2
   c_id customers.id%type := 1; 
   c_sal  customers.salary%type; 
   SELECT  salary  
   INTO  c_sal 
   FROM customers 
   WHERE id = c_id; 
   IF (c_sal <= 2000) THEN 
      UPDATE customers  
      SET salary =  salary + 1000 
         WHERE id = c_id; 
      dbms_output.put_line ('Salary updated'); 
   END IF; 

Key Points

  • PL/SQL - Control Statements
  • Image