Pages

Wednesday, April 27, 2016

Code Example: bash calling sql code with sqlplus.

========================
General
========================
This is a simple, logic free, example of bash script calling a sql code with sqlplus.

========================
Code
========================
set_export_user.sql
export_black_list.sh
export_black_list.sql

========================
set_export_user.sql
========================
define exp_user=my_user
define exp_pass=my_pass
define connectstr=orainst

========================
export_black_list.sh
========================
#!/bin/bash

clear
echo
echo "***********************************"
echo "***** Start Black List Export *****"
echo "***********************************"
echo

sqlplus /nolog << EOF
@./export_black_list.sql
EOF

echo
echo "Extract Files Are Going to be Generated Under $WORK_HOME"
echo "This might take a few minutes to complete..."
echo
echo "***********************************"
echo "*****  End Black List Export ******"
echo "***********************************"
echo


========================
export_black_list.sql
========================
conn &&exp_user/&&exp_pass@&&connectstr

BEGIN
  EXTRACT_UTIL_PKG.RUN_BL_EXTRACT_JOB;
END;
/
EXIT

No comments:

Post a Comment