PL/SQL Exception

PL/SQL Exception

PL/SQL Interview Questions

PL/SQL Interview Questions and Answers


PL/SQL If Then Statement

The IF statement in PL/SQL is used to check the specific condition before execute single or block of statements only when condition is TRUE. PL/SQL allows you to write programming language features like IF statement to make your code decision making. If the condition is "true" then block will be executed, otherwise block will not be executed.

PL/SQL IF THEN Statement Syntax

To check a specific condition before execute block statements only when condition is TRUE, use the following syntax:

Syntax

PL/SQL IF THEN Statement example

The following PL/SQL IF THEN statement is used execute block statement only if condition is TRUE:

Example

PL/SQL IF THEN ELSE Statement Syntax

To check a specific condition before execute block statements only when condition is TRUE, otherwise execute other block statements if condition is FALSE, use the following syntax:

Syntax

PL/SQL IF THEN ELSE Statement example

The following PL/SQL IF THEN ELSE statement is used to execute block statement only if condition is TRUE otherwise execute other block statements if condition is FALSE:

Example

PL/SQL IF THEN ELSIF Statement Syntax

To check a multiple conditions, if condition1 is TRUE execute block statement for contition one, otherwise execute other block statements for contition two, if condition2 is TRUE, use the following syntax:

Syntax

PL/SQL IF THEN ELSIF Statement example

The following PL/SQL IF THEN ELSIF statement is used to execute block statement only if condition1 is TRUE, otherwise execute other block statements for contition two, if condition2 is TRUE:

Example

PL/SQL IF THEN ELSIF ELSE Statement Syntax

To check a multiple conditions, if condition1 is TRUE execute block statement for contition one, execute other block statements for contition two, if condition2 is TRUE otherwise execute other block statement if condition1 and condition2 are FALSE, use the following syntax:

Syntax

PL/SQL IF THEN ELSIF Statement example

The following PL/SQL IF THEN ELSIF statement is used to execute block statement only if condition1 is TRUE, execute other block statements for contition two, if condition2 is TRUE otherwise execute other block statement if condition1 and condition2 are FALSE:

Example