Hi everyone,
When I run the shell script to execute the SQL script so it can pick up the value
from the loopcount. The SQL script does not recognize the $. How can I make it
to work. Below is the sample script.
Hi Alenz,
I want to thank you for your help. I tried your method and I'm not sure if I did it
correctly. It didn't work. My sql scripts are below. It didn't recognize the $.
ksh script:
i=1
sqlplus -s @myscript.sql $i
sql script:
SET SERVEROUTPUT on
DEFINE loopcount = $i
DECLARE
v_test NUMBER := &loopcount;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_test);
END;
/
I think this should work :
this is the shell script
i=1;export i
sqlplus -s system/complex <
set serverout on;
define loopcount=$i
declare
v number :=&loopcount;
begin
dbms_output.put_line(v);
end;
oh it missed out some characters let me try again basically there is an exclamation mark after two less than signs at the end of the sqlplus line and an exclamation mark at the end of the file:
i=1;export i
sqlplus -s system/complex <
set serverout on;
define loopcount=$i
declare
v number :=&loopcount;
begin
dbms_output.put_line(v);
end;
/
!
Hi Knarayan,
thanks for your assistance but it didn't work. My OS is HP and I used
kornshell script. It didn't work. It kept saying DEFINE and DECLARE not found.
Below is my kornshell script.
userid=apple
export i=1
$ORACLE_SQLPLUS -s $apple/$apple < set serverout on;
DEFINE loopcount = $i
declare
v_test number := &loopcount;
begin
dbms_output.put_line(v_test);
end;
/
Originally posted by Trina Hi Alenz,
I want to thank you for your help. I tried your method and I'm not sure if I did it
correctly. It didn't work. My sql scripts are below. It didn't recognize the $.
ksh script:
i=1
sqlplus -s @myscript.sql $i
sql script:
SET SERVEROUTPUT on
DEFINE loopcount = $i
DECLARE
v_test NUMBER := &loopcount;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_test);
END;
/
change
DEFINE loopcount = $i
to
DEFINE loopcount = &1
Bookmarks