Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL*PLUS - how run scripts?

Re: SQL*PLUS - how run scripts?

From: Anton Buijs <remove_aammbuijs_at_xs4all.nl>
Date: Wed, 6 Aug 2003 19:47:53 +0200
Message-ID: <3f313f52$0$49103$e4fe514c@news.xs4all.nl>

Karsten Farrell <kfarrell_at_belgariad.com> schreef in berichtnieuws MPG.199ad0114585722c98982a_at_news.la.sbcglobal.net...
| Hi Randy Nichols, thanks for writing this:
| > There is something that should be simple but I cannot find how to do it.
| >
| > In SQL*PLUS, the "@" command runs scripts. But you have to know the
path
| > (unless it is in certain directories).
| >
| > The "File | Open" function allows you to browse for a file, but
"opening" a
| > file is different from running it. (My impression is that you can only
open
| > a file with a single command in it, whereas you can run scripts with
many
| > commands in it, including SQL*PLUS commands and PL/SQL blocks.)
| >
| > How do you browse to a script file to run it in SQL*PLUS?
| >
| > Thanks,
| >
| > Randy Nichols
| >
|
| If you set the SQLPATH variable (environment variable most places;
| registry for Win), you don't need the path (or can use a relative path
| from one of the paths specified in SQLPATH). This means you have to keep
| most of your SQL scripts in common directories.
|
| You can File / Open a script containing many commands, but it won't run
| (correctly). You can use this to set your current directory to where you
| keep all your scripts (open any script, ctrl-c, then use "@" to run any
| script in that directory). This is also useful if you spool your output to
| a file, then host out to DOS (so you don't end up spooling everything to
| the "bin" directory).
|
| If you use a double-ampersand ("@@"), it means run the script in the
| current directory (in case you have another script by the same name in a
| different directory).
| --
| [:%s/Karsten Farrell/Oracle DBA/g]

May I precise this a bit.
On Windows you set registry key HKLM\Software\Oracle\Home<n>\SQLPATH or a variable SQLPATH in a DOS box as a list of directories separated by a ";". On Unix the variable is called ORACLE_PATH. When you call a script (@x.sql) Sql*Plus will search these directories and run it from the first directory where it is found.

The @@ means that when @@y is a line in script x.sql than y.sql will looked for in the same directory as where x.sql was found. When @@ is used not from a another script file, @@ means the same as @. Received on Wed Aug 06 2003 - 12:47:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US