You are on page 1of 5

The DECLARE Clause

• DECLARE Clause Objects


• Available Data Types
• Declare Simple Types
• Declare Complex Types
• %TYPE
• %ROWTYPE
• TYPE…TABLE
• TYPE…RECORD
• User-Defined Types

Oracle 11g PL/SQL Fundamentals I


DECLARE Clause Objects
The DECLARE Clause is used to define
(declare) internal program objects, such as
variables.
• The following
Object
are among PL/SQL objects
Explanation
Variable An element internal to the program that can
hold and modify values.
Boolean A simple type containing TRUE/FALSE/NULL
Constant Similar to a variable, but cannot be changed.
Record Complex object that matches the structure of a
table within the database yet holds a single
record.

Oracle 11g PL/SQL Fundamentals I


DECLARE Clause Objects (cont)
Object Explanation
Table Complex object that matches the structure of
a table within the database.
User- A type that uses a combination of the
defined predefined objects to create a new type
type unique to the program.

DECLARE
--Define variables
EmpLname VARCHAR2(20);
EmpSalary NUMBER(6);
EmpBdate DATE;

BEGIN

END;

Oracle 11g PL/SQL Fundamentals I


Object Name Rules
When selecting a name for a declared object,
there are some rules you must follow:
• Maximum length is 30 characters.
• The first character must be a letter.
• The following table outlines characters that are
legal and illegal.
Legal Illegal
$ &
# - (dash)
_ (underscore) /
(space)

Oracle 11g PL/SQL Fundamentals I


See it in action

Oracle 11g PL/SQL Fundamentals I

You might also like