PL/SQL Variables

PL/SQL allows multiple types of data that can be used to declare variables. Optional  variables can be assigned values ​​in the declaration, and can change the value by subsequent assignments in the block.

Types of Variables

– PL/SQL variables:

  • Scalar
  • Composite
  • Reference
  • LOB (large objects)

– Non-PL/SQL variables: Bind and host variables

Syntax

variable_name datatype [NOT NULL] [:= | DEFAULT initial_value];

Example

string_variable   varchar2(50) := 'TEST';
number_variable   number(3) := 456;
date_variable     date(20) := sysdate;
type_variable     table_name.column_name%TYPE;
record_variable   table_name%ROWTYPE;
boolean_variable  BOOLEAN;
file_variable     Bfile;
store_variable    BLOB;