Re: Setting Directory Path in SQL*Plus

From: Rauf Sarwar <rsarwar_at_ifsna.com>
Date: 4 Jun 2002 15:35:59 -0700
Message-ID: <c2d690f2.0206041435.7d48bf46_at_posting.google.com>


Bricklen Anderson <bricklen_at_shaw.ca> wrote in message news:<3CFC278B.B0EB772B_at_shaw.ca>...
> alt.msdos.batch.nt is also good forum for this question (more likely to
> get an informative answer).
> One environment variable that I can think of offhand is %WINDIR% , which
> will get you (eg.) C:\WINNT
> or try like cd %WINDIR%\.. to go up to the root drive (can't remember
> what the root drive %...% name is).
>
> hth
>
> Bricklen
>
> Justin Wigg wrote:
> >
> > Hi all...
> >
> > I am trying to write an master installation script that will install many
> > tables, packages etc into an Oracle 8.1.7 database by calling several large
> > subscripts in sequence.
> >
> > A certain directory structure has been created (for a good reason) to store
> > these subscripts in different places but all within a master directory.
> > What I am trying to do is set the master script up so that it can point
> > itself to a different sub-directory and call a script but to do so relative
> > to the original directory.
> >
> > This will be running on Windows 2000 Server, but I don't want to actually
> > hard code the directory path into the script as there is no guarantee that
> > the drive names will be the same etc, so I don't just want to say
> > "_at_E:\etc\etc\etc".
> >
> > Is there any way I can change directories in an SQL script by using a
> > DOS-style command or something to do something like "cd
> > ..\..\scripts\blah\blah"? Is there maybe an environment variable I can't
> > find that will do this?
> >
> > Many thanks...
> > --
> > "Managing senior programmers is | Justin Wigg - Hobart, AUSTRALIA
> > like herding cats." - Dave Platt | Reply: justin_at_icsmultimedia.com.au

From command line change directory to where your master script is. e.g. C:>\ cd blah\blah\MyMasterScript
So what you will see is C:\blah\blah\MyMasterScript> Note: You can launch all this from a batch file.

Launch sqlplus from here and pass your Master script as argument like sqlplus username/password_at_db_alias @MyMasterScript

In the script, you can reference and run other scripts which are UP or BELOW your working directory by,

SQL> _at_.\blah\BelowScript\Script.sql -- Going below relative to your directory
SQL> _at_..\blah\UpScript\Script.sql -- Going above relative to your directory
SQL> _at_..\..\blah\UpUpScript\Script.sql -- Going two level above relative to your directory etc etc.

Hope this helps
Regards Received on Wed Jun 05 2002 - 00:35:59 CEST

Original text of this message