Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL*Plus script with a dynamic SPOOL File Location?

390534Oct 10 2007 — edited Oct 10 2007
Anyone,

I have a numbr of SQL Plus scripts that I need to run many times but each run against a different database. Each script SPOOLS the output like this:
spool c:\temp\BUILD_ASSET.lis
spool c:\temp\BUILD_WORKORDER.lis
...
etc
(each spool is a seperate script run)
The spool is at the top of each BUILD SQL Script.
Example:
set time on
SET FEEDBACK ON
SET ECHO ON
SET TIMING ON
spool c:\temp\BUILD_ASSET.lis
But I need each run to go into its own directory based on the database I am connected to. Like this:
CONNECT DB1
@C:\temp\BUILD_ASSET.SQL =====> spool c:\temp\DB1\BUILD_ASSET.lis


@c:\temp\BUILD_WORKORDER.SQL =====>  spool c:\temp\DB1\BUILD_WORKORDER.lis

...
etc

CONNECT DB2
@C:\temp\BUILD_ASSET.SQL =====> spool c:\temp\DB2\BUILD_ASSET.lis


@c:\temp\BUILD_WORKORDER.SQL =====> spool c:\temp\DB2\BUILD_WORKORDER.lis
Is there a way to dynaically code this without having to create a version of the BUILD scripts for every single DB I connect to?

I would like to have one big script that executes all the individual BUILD scripts.

Seems very easy in concept but I can not see an easy way. I would appreciate any help I can get.

Thanks in advance,
Miller
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2007
Added on Oct 10 2007
2 comments
468 views