Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: November 22, 2016 - 9:37 pm UTC

Last updated: November 23, 2016 - 11:08 am UTC

Version: oracle 11g

Viewed 1000+ times

You Asked

Hi,

I have a sql file which will take schema name prefix as the parameter.This file in turn will call various sql files and all these files use this variable to do the job.

I execute this file like this:

sql> @execute_scripts.sql &&1
Enter the value of 1: (Here i give the schema name)

In another file I use a table name, so the code is as follows:

select * from &&1._crust.table_name;

Depending on the value of 1 it will go and access the table in that particular schema.

Now, my question is I want to write a batch file which will call all these sql files. How to pass this variable to this batch file so that it will be used in all these sql files. Please can someone give me some suggestions.

Many Thanks

and Connor said...

In windows:

myscript.bat
============
sqlplus @myscript %%1

In Unix

myscript.ksh
============
sqlplus @myscript $1

will let you pass a schema from the command line, and then onto SQL Plus




Is this answer out of date? If it is, please let us know via a Comment