How to Initialize Variable in PL/SQL

In this article I am going to explain how to initialize variable in PL/SQL.
  • 2496


PL/SQL is define as procedure language/structure query language.  PL/SQL is developed by oracle. PL/SQL supports many feature like variables, loops, conditions  and exceptions. It also support the concept of array. In present time PL/SQL is integrated component of oracle software. SQL provide limited support for advance programming and PL/SQL fill this gap.

Block is a basic unit of a PL/SQL application. This block is collection of PL/SQL statements grouped as logical unit. Using  PL/SQL blocks you can create five different type of program units.

  1. Stored Function
  2. Stored procedure
  3. Anonymous Block
  4. Trigger
  5. Package

Syntax for declaring a variable in PL/SQL

Varriable_Name DataType; 

Syntax for Initializing a variable in PL/SQL

Varriable_Name := Value;

Varriable_Name DataType := Value;

Here Variable_Name is name of variable and DataType is a valid data type.


st_marks VARCHAR2(15);
st_id CONSTANT NUMBER(10) := 2;
SELECT s_marks into st_marks FROM student WHERE s_id=st_id;

© 2020 DotNetHeaven. All rights reserved.