Unknown

PL/SQL-(Tutorial-02)-Variable



Variable:

AS we discueed our first tutorial all variable declaration done in DECLARATION section of the PL/SQL.



1. Variable_name is the valid identifier in PL/SQL

2. Datatype must be valid PL/SQL datatype.

3. NOT NULL is an optional specification on the variable.

4. Value or DEFAULT valueis also an optional specification, where initialize a variable.

5. Each variable declaration is a separate statement and must be terminated by a semicolon.



Variable Example01:



SET SERVEROUTPUT ON;

DECLARE

V_Numeric NUMBER;

BEGIN

V_Numeric:= 10;

DBMS_OUTPUT.PUT_LINE ('Numeric value is' ||' '||V_Numeric);

END;



Here we assign variable in "BEGIN" section.









we can initialize a variable in different ways.

1

2

Variable Example02:

SET SERVEROUTPUT ON;

DECLARE

V_Numeric NUMBER:=10;

BEGIN

DBMS_OUTPUT.PUT_LINE ('Numeric value is' ||' '||V_Numeric);

END;

Assignment Operator (:=):

Reactions:

. First is the direct way of giving value to the variable which is Demonstrated by "Variable Example01"..Second way is fetching value from the column of a row of a table and assigning that value to the variable.Here we assign variable in "DECLARATION" Sectionhere we used conventional assignment operators in other programming language which is Equal to (=) operator, here we used colon ( : ) with equal to (=) operator for assigning the value to the variable.This sign works as assignment operator which is very different from the other programming languages.Note: There is no space between colon and equal to operator.***************************Thank You******************