Specifies a user variable and assigns it a CHAR value, or lists the value and variable type of a single variable or all variables.
Syntax
DEF[INE] [variable]|[variable = text]
Terms and Clauses
Refer to the following list for a description of each term or clause:
variable | Represents the user variable whose value you wish to assign or list. |
text | Represents the CHAR value you wish to assign to variable. Enclose text in single quotes if it contains punctuation or blanks. |
variable = text | Defines (names) a user variable and assigns it a CHAR value. |
Usage Notes
DEFINEd variables retain their values until one of the following events occurs:
Note that you can use DEFINE to define the variable, _EDITOR, which establishes the host system editor invoked by the SQL*Plus EDIT command.
If you continue the value of a DEFINEd variable on multiple lines (using the SQL*Plus command continuation character), SQL*Plus replaces each continuation character and carriage return you enter with a space in the resulting variable. For example, SQL*Plus interprets
SQL> DEFINE TEXT = 'ONE- > TWO- > THREE'
as
SQL> DEFINE TEXT = 'ONE TWO THREE'
Examples
To assign the value MANAGER to the variable POS, type:
SQL> DEFINE POS = MANAGER
If you execute a command that contains a reference to &POS, SQL*Plus will substitute the value MANAGER for &POS and will not prompt you for a POS value.
To assign the CHAR value 20 to the variable DEPTNO, type:
SQL> DEFINE DEPTNO = 20
Even though you enter the number 20, SQL*Plus assigns a CHAR value to DEPTNO consisting of two characters, 2 and 0.
To list the definition of DEPTNO, enter
SQL> DEFINE DEPTNO DEFINE DEPTNO = "20" (CHAR)
This result shows that the value of DEPTNO is 20.