RelationalDBDesign RelationalDBDesign


SQL* Plus CLI  «Prev 

@@ command in Oracle

When you write one script that calls another, you may end up storing both scripts in the same directory because they are related. When the first script calls the second, it stands to reason that you want SQL*Plus to start its search from the directory that contains the scripts. You can use the @@ command for this. When you use the @@ command from within one script to call another, SQL*Plus starts its search in the directory containing the first script. The following table illustrates the difference between @ and @@:

Step 1: @filename @@filename
Step 2: SQL*Plus looks in the current working directory SQL*Plus looks in the directory that contains the parent script.
Step 3: SQL*Plus follows the search path SQL*Plus follows the search path

The difference between the two commands is in step 2, or the first directory to be searched. Using @@ to invoke one script from within another allows you to avoid any problems that might be caused by having two or more scripts with identical filenames in your sqlpath. Regardless of where SQL*Plus starts its search, it stops when it finds a file with the name that it is looking for. Step 3 will only be performed if a file was not found in step 2.

@@ (double at sign)

Syntax
@@{url | file_name[.ext] } [arg...]
Runs a script. This command is almost identical to the @ (at sign) command. When running nested scripts it looks for nested scripts in the same path or url as the calling script. The @@ command functions similarly to @ and START.

Terms

url: Specifies the Uniform Resource Locator of a script to run on the specified web server. SQL*Plus supports HTTP and FTP protocols, but not HTTPS. HTTP authentication in the form
http://username:password@machine_name.domain... 
is not supported in this release.
file_name[.ext]

Represents the nested script you wish to run. If you omit ext, SQL*Plus assumes the default command-file extension (normally SQL).
For information on changing the default extension, use SET SUF[FIX] {SQL | text}. (See below) When you enter @@file_name.ext from within a script, SQL*Plus runs file_name.ext from the same directory as the script. When you enter @@file_name.ext interactively, SQL*Plus runs file_name.ext from the current working directory or from the same url as the script from which it was called. If SQL*Plus does not find the file, it searches a system-dependent path to find the file. Some operating systems may not support the path search. See the platform-specific Oracle documentation provided for your operating system for specific information related to your operating system environment.

SET SUF[FIX] {SQL | text}

Sets the default file extension that SQL*Plus uses in commands that refer to scripts. SUFFIX does not control extensions for spool files.
Example To change the default command-file extension from the default, .SQL to .TXT, enter
SET SUFFIX TXT
If you then enter
GET EXAMPLE
SQL*Plus will look for a file named EXAMPLE.TXT instead of EXAMPLE.SQL.