Thursday 6 October 2022

Call Oracle Stored Procedure from Shell Script

 #!/bin/bash


export ORACLE_HOME=/u01/app/oracle_home

export PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_SID=ERPCDB1

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib


l_user='apps'

l_psw='Admin1234'

l_conn_string='mydb'


sql_error=`sqlplus -silent $l_user/$l_psw@$l_conn_string <<END

WHENEVER SQLERROR EXIT 1

begin

/* Call compute_sal stored procedure */

  XX_AP_PAY_BATCH_JOB_PRC;

exception

 when others then

  raise;

end;

/

 EXIT;

END`


Result=$?


echo $Result


if [[ $Result -ne 0 ]]

then

  echo "${sql_error}"

  echo "Error calling the PL/SQL procedure."

  exit $Result

else

  echo "PL/SQL Procedure executed successfully."

  exit 0

fi


No comments:

Post a Comment

Number of Visitors