I am satyakiran , i am new to the forum. i never done shell scripts for connecting to the data base (oracle) and fetching the data from the database( thru sql select statements ) i want to know
how to connect to the data base(oracle) using shell script
how to retrieve data from data base
how to process the data retrieved from database (i.e result set)
Suppose u hav written a script for scheduling job using "crontab",and u r doing ur job.
But according to requirement u need to change the execution of that job to some other time.What is the solution of that.
Actually in an interview someone asked me.I told ,i will change value for time in the crontab.
Here's my simple code that may solve your problem.
Lets say you have a 'usr' table with 'user ID, user Name, status (Active(A) or Suspended (S))'
Connection to DB is established wrt DB name in the tnsnames entry
Select/update query will retrive/update the information from the table resp.
#!/bin/ksh
echo "Please enter the User Id of the USER whose status needs to be activated"
read usrId
sqlplus username/password@database_name <<ENDOFSQL
set head off;
set feedback off;
set lines 300;
select * from usr where usrid='$usrId';
update usr set status='A' where usrId='$usrId';
ENDOFSQL
echo " "
echo "User Activated :: `echo $usrId`"
echo " "
exit;