Oracle Server Manager User's Guide

Contents Index Home Previous Next

VARIABLE

Purpose

Declare a bind variable for use in the current session with the EXECUTE or PRINT command, or for use with a PL/SQL block.

Prerequisites

None.

Syntax

VARIABLE command ::=

where:

name The name of the bind variable you wish to define.
type The datatype of the bind variable. The valid datatypes are NUMBER, CHAR, and VARCHAR2. You can specify a length from 1 to 255 for CHAR, and from 1 to 2,000 for VARCHAR2. If you do not specify a length, CHAR and VARCHAR2 default to the current setting of CHARWIDTH.

Usage Notes

Bind variables defined with the VARIABLE command exist until the end of the session. Variables defined in your session cannot be accessed or changed by a different session.

Warning: CHAR variables are fixed length, padded with blanks. VARCHAR2 variables are variable length. You must use CHAR when passing a character variable to a PL/SQL procedure that defines a CHAR parameter. Otherwise, a conversion error results. A PL/SQL procedure that expects a VARCHAR2 variable, on the other hand, will automatically convert a CHAR parameter to the proper form. (In general, it is a good idea to avoid the use of CHAR variables in PL/SQL procedures unless blank-padding is an absolute requirement.)

Note: In V6 compatibility mode, a CHAR variable is variable length, rather than fixed.

Examples

VARIABLE balance NUMBER

VARIABLE ename CHAR(20) 


Contents Index Home Previous Next