Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Conditional Control Structures

The document explains control structures in PL/SQL, which alter the logical flow of statements. It details four basic types: conditional control, iterative control, sequential control, and unconditional branching, focusing on conditional control statements such as IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSEIF. Each type of conditional statement has specific syntax and examples demonstrating their use in executing statements based on certain conditions.

Uploaded by

lokibeaver
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Conditional Control Structures

The document explains control structures in PL/SQL, which alter the logical flow of statements. It details four basic types: conditional control, iterative control, sequential control, and unconditional branching, focusing on conditional control statements such as IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSEIF. Each type of conditional statement has specific syntax and examples demonstrating their use in executing statements based on certain conditions.

Uploaded by

lokibeaver
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 4

CONTROL STRUCTURES

 Control structure enables the program to change the logical flow of statements
within PPL/SQL.
 PL/SQL supports 4 basic programming control structure :-
i) Conditional control
ii) Iterative control
iii) Sequential control
iv) Unconditional Branching

i)CONDITIONAL CONTROL STATEMENTS :-


 We can execute a statement sequence or sequence of statements conditionally with
IF-THEN-ELSE Statement .

 There are 3 Conditional control statements. They are.,


i) IF-THEN Statements
ii) IF-THEN-ELSE Statements
ii) IF-THEN-ELSEIF Statements
i)IF-THEN Statements :-
It is the simple form.
Syntax :-
IF condition THEN
Statement (s);
END IF ;
 The statements that immediately follow the conditional IF statement are
Executed only if the condition evaluation is TRUE. If the condition evaluates to
FALSE, the statements are not processed and are passed over.
Example ,
IF grade = ‘A’ THEN
UPDATE employee_table SET tax = salary * 0.4;
END IF;
ii)IF-THEN-ELSE Statements :-
Syntax :-
IF condition THEN
Statement (s);
ELSE
Statement (s);
END IF ;
 The statements that immediately follow the conditional IF statement are
Executed only if the condition evaluation is TRUE. If the condition evaluates to
FALSE, the immediately following the ELSE portion are executed .
Example ,
IF grade = ‘A’ THEN
UPDATE employee_table SET tax = salary * 0.4;
ELSE
UPDATE employee_table SET tax = salary * 0.3;
END IF;
 Each IF THEN statement can have only one ELSE statement and must
end with an END IF statement.
iii)IF-THEN-ELSEIF Statements :-
 In some structure, we need to select an action from several mutually exclusive alternatives. The IF-
THEN-ELSEIF statements give the solution for this.
Syntax :-
IF condition1 THEN
Statement (s);
ELSEIF condition2 THEN
Statement (s);
ELSE
Statement (s);
END IF ;
Example ,
IF num1>num2 THEN
dbms_output.put_line(‘Num1 is greater than num2’);
ELSEIF num1 = num2 THEN
dbms_output.put_line(‘both numbers are equal’);
ELSE
dbms_output.put_line(‘num2 is greater than num1’);
END IF;

You might also like