Variables

The declaration section of the PLSQL bloke is where you can set up variables that will be used throughout the code – a variable is used to store temp data for use in that specific code execution.

Syntax

[ CONSTANT ] [ := ];

Example

When setting a variable within PLSQL you can set it to be a CONSTANT i.e. the specified initial value set cannot be changed. You can also set a default value for a standard variable.

v_employee_surname VARCHAR2(50) := ‘Smith’;

You can also set the datatype as a table type – to mimic what the table datatype is.

t_employee_name EMPLOYEE.surname%TYPE := ‘Smith’;

Leave a Reply

Your email address will not be published. Required fields are marked *