Oracle Variable – DEF, UNDEF, ACCEPT, COLUMN

A reference post. See the syntax for various commands

DEF variablename=value Define variable variablename, if not already defined, and set its value to value
DEF variablename Show the value and type of variablename
DEF Show the value and type of all currently defined variables
UNDEF variablename Undefine variablename
ACCEPT variablename [type] [FORMAT format] [DEFAULT defaultvalue] [PROMPT prompt_text | NOPROMPT] Define variablename, if not already defined, and read a line of input into it. Prompt user for that input with prompt_text, if supplied, and check the user’s input againt FORMAT if supplied.
COLUMN columnname [ NEW_VALUE variablename | OLD_VALUE variablename ] When a query with a column named columnname in its resultset is run, defines variablename and puts the column value in variablename
CLEAR COLUMNS Clears formatting and NEW_VALUE / OLD_VALUE on columns. Does not undefine any variables.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s