Embedding a SQL inside Shell Script:-
Here is a tip on how to run sqlplus scripts within a shell script.
This is an example of how to pass database values into shell variables, and to make shell scripts more dynamic. This will help DBA to automate certain DBA tasks, also to setup some automation using cron.
VAR1=`sqlplus -s username/password <<end
set pagesize 0 feedback off ver off heading off echo off
select sysdate from dual;
echo “system date is ” $VAR1
#end of shell script
This will retrieve the system date from Oracle but you get the idea that you can expand the select script to get whatever you want from the database and place it in a shell variable where you can make decisions on it.