Operating System - HP-UX
1753873 Members
7790 Online
108809 Solutions
New Discussion юеВ

Re: Calling sqlplus scripts from unix

 
Brian Gebhard
Occasional Advisor

Calling sqlplus scripts from unix

Inside an Unix script I call a sqlplus script and pass 6 parameters. Inside the sqlplus script I use &1 - &6. I call multiple sqlplus scripts inside the 1st sqlplus script using &1-&6 as the paramters. I call 3 different ones one using &1 &2, 2nd using &3 &4, 3rd using &5 &6. Now when i call my 4th sqlplus plus script I try using &1 again but instead of using the original value of &1 it uses the value of &5. My believe is that once I call another sqlplus script that takes arguments, it then resets &1 to that current value for all lvls. Therefore when I come back up one lvl and try to use the old value for &1 it has been reset to the whatever the value was that I used when calling the last sqlplus script. Is this how it is supposed to work or am I am doing something wrong. Or is there another way to do this.

unix script
sqlplus_script_1 v1 v2 v3 v4 v5 v6
sqlplus_script_1_1 &1 &2
sqlplus_script_1_2 &3 &4
sqlplus_script_1_3 &5 &6
(ALL THE ABOVE SCRIPTS WORK FINE)
sqlplus_script_1_4 &1 &2
(Now sqlplus_script_1_4 uses the value for v5 and v6 instead of using v1 v2.)

Is this how it is supposed to work.



4 REPLIES 4
Volker Borowski
Honored Contributor

Re: Calling sqlplus scripts from unix

Hi brian,
I think the problem is, by calling those scripts, you reassign values to &1 &2 all the time. May be you schould print &1 &2 between those calls. I think it will show them destroyed after the second call.

You schould save the values after the first call:
DEFINE P1 = &1
DEFINE P2 = &2
...

and call your scripts with those variables.

Hope this helps
Volker
Joseph C. Denman
Honored Contributor

Re: Calling sqlplus scripts from unix

I agree that that would fix your problem. If you set up the variables as state. script 4 could be executed as:

sqlplus_script_1_4 ${P1} ${P2}

If I had only read the instructions first??
Brian Gebhard
Occasional Advisor

Re: Calling sqlplus scripts from unix

Thank you for your help. I changed the script and set those 6 arguments to variables and it works fine now.
Volker Borowski
Honored Contributor

Re: Calling sqlplus scripts from unix

How about points ?
Just to keep in mind how this forum works.
Best Regards
Volker