PL/SQL Variable


Prev Tutorial Next Tutorial

PL/SQL Variable

AVariable is an identifier which holds data or another one variable is an identifier whose value can be changed at the execution time of program.

Variable declaration

Syntax

variable_name datatype;

Example

a number;

Variable Initialization

Syntax

variable_name datatype:=value;

Example

a number=10;

Rules for variable declaration

  • Variable name start with alphabet.
  • Variable name contains minimum one character and maximum 30 character.
  • It should not allow any space and any special character.
  • Keywords are not allow to declare as a variable name.

Example of variable declaration and initialization.

Example

DECLARE
num1 number; 
num2 number; 
BEGIN 
num1 := 10; 
num2 := 20; 
DECLARE 
c number; 
BEGIN 
c := num1 + num2; 
dbms_output.put_line('Sum: 'c);
END; 
END;

Output

Sum: 30

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements