Database Reference
In-Depth Information
You can also use the DEFINE command to set the value of the variable
before executing the query. It follows that the value of the CDNUM vari-
able can be predefined as a value, negating the need for a user prompt.
DEFINE CDNUM=2
/
And remove a defined variable from your session using the UNDEFINE
command.
UNDEFINE CDNUM
Use the SAVE command to write the SQL buffer contents to a file so
you can edit and run it whenever you want. This also allows you to add
SQL*Plus commands to the file, which do not get saved when working
only with the SQL buffer file.
SAVE CDREPORT
The file is named CDREPORT.SQL. The .SQL extension is a default. If
you specify the extension (suffix) in the SAVE command file name, the
default .SQL is overridden with the specified extension. Now that the query
is inside a file, you can edit the file with the following command:
EDIT CDREPORT
The editor is instantiated as before, but the file you are editing is now the
CDREPORT.SQL file, rather than the SQL buffer's default file. You could
add the following line of code to the beginning of the file. The ACCEPT
command is another method of defining a variable that is used in a query.
The PROMPT variation can be added as an option to define the text
SQL*Plus displays when prompting you to enter a value for the variable.
ACCEPT CDNUM PROMPT 'What CD number do you want to see? '
Save the file and exit the editor to return to SQL*Plus. Notice that the
buffer was not re-displayed this time. To run the file you just edited, you
should use the START command because the SQL*Plus script is now in a
 
Search WWH ::




Custom Search