1

I have two SQL scripts which get called within a loop that accept a number parameter. Here is what I'm currently using:

for /l %%i in (1, 1, 51) do (
    sqlplus u/p@name @script.sql a%%i.html %%i
    sqlplus u/p@name @script.sql b%%i.html %%i
)

Everything works fine, but it seems like a waste of time and resources to connect twice for each pass through. Is there a way I could simply log into sqlplus, run the for loop, then exit? I tried many alternatives such as putting

sqlplus u/p@name

before the for loop, but then it would simply hang at the SQL> prompt without executing any of my two scripts.

Thank you.

2 Answers 2

3

You can create a masterscript.sql that contains your two script.sql statements. The only thing I'm not sure about is if it will pass in your variables.

MasterScript.sql would contain:

@@script1.sql
@@script2.sql

and neither of your sub-scripts should contain an exit.

Differences between "@" and "@@":

http://www.orafaq.com/wiki/SQL*Plus_FAQ#What_is_the_difference_between_.40_and_.40.40.3F

Sign up to request clarification or add additional context in comments.

Comments

0

Try This

( echo @%query% user )
| sqlplus username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=XX.XX.XX.XX)(Port=152X))(CONNECT_DATA=(SID=ABC)))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.