Hi,
I wrote a shell script where I connect to an oracle db(the connection works because I able to see the DBMS output) and I execute a procedure, but I am not able to get the return value from that procedure into one of the shell variables (i understand that procedure do not return values but i am using IN OUT and i want this out value to go into a variable declared in the shell). I made sure the procedure works in sqlplus and the OUT value is comming out. Below is the code.
LOGIN=user1
DB_PWD=`some passwork`
sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;
declare
ERRFLAG number := 0;
begin
procedure_retur n_error(ERRFLAG );
dbms_output.put _line(ERRFLAG); /* the value gets displayed here which means the sql connection works and the OUT value is comming through */
end ;
/
!
echo errorflag is ${ERRFLAG} /* the value does not come here and dont mind the ${ERRFLAG} it does not work with just $ERRFLAG either */
echo ${APPS_LOGIN}
exit 0
I also tried declaring a global variable like below:
LOGIN=user1
DB_PWD=`some passwork`
ERRFLAG = 0 // like this but this does not work either
sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;
begin
procedure_retur n_error(ERRFLAG );
dbms_output.put _line(ERRFLAG); // the value gets displayed here
end ;
/
!
echo errorflag is ${ERRFLAG} // the value does not come here
echo ${APPS_LOGIN}
exit 0
Please reply,
thank you.
I wrote a shell script where I connect to an oracle db(the connection works because I able to see the DBMS output) and I execute a procedure, but I am not able to get the return value from that procedure into one of the shell variables (i understand that procedure do not return values but i am using IN OUT and i want this out value to go into a variable declared in the shell). I made sure the procedure works in sqlplus and the OUT value is comming out. Below is the code.
LOGIN=user1
DB_PWD=`some passwork`
sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;
declare
ERRFLAG number := 0;
begin
procedure_retur n_error(ERRFLAG );
dbms_output.put _line(ERRFLAG); /* the value gets displayed here which means the sql connection works and the OUT value is comming through */
end ;
/
!
echo errorflag is ${ERRFLAG} /* the value does not come here and dont mind the ${ERRFLAG} it does not work with just $ERRFLAG either */
echo ${APPS_LOGIN}
exit 0
I also tried declaring a global variable like below:
LOGIN=user1
DB_PWD=`some passwork`
ERRFLAG = 0 // like this but this does not work either
sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;
begin
procedure_retur n_error(ERRFLAG );
dbms_output.put _line(ERRFLAG); // the value gets displayed here
end ;
/
!
echo errorflag is ${ERRFLAG} // the value does not come here
echo ${APPS_LOGIN}
exit 0
Please reply,
thank you.
Comment