Hi All,
I am in a problem here is the description,
Actually in my shell script i am firing a mysql query which returns multiple records and i have to process each record one by one.
So could any one please suggest me how to solve my problem?
Thanks in Advance
Ashok Sharma
Can You post what data ( sample) your mysql query is returning and what do you want to do with that.
Thanks for quick reply,
MySQL query returns data like this
ID ORG_ID TRANS_ID
1 2180 10
2 2186 11
3 2198 12
Now i want to loop through the individual row and will call different stored proc based on TRANS_ID.
something like this :
for i in `awk { print $3 }' my_sql_op.txt`
do
if [ $i -eq 10 ] ; then
### execute the procedure1 by calling sqlplus ..(for oracle) Proc1 ( $i );
else
####proc2 ($1);
fi
done
Actually i have data in SQLRESULT variable, which i am getting by below statement
SQLRESULT=$(/usr/bin/mysql -uabc -pabc abc -sN -e "SELECT ID, ORG_ID, TRANS_ID FROM SS_TRIGGERED_EVENT WHERE STATUS = 'P' ;")
and when i use below statement i get a single line containing all the rows like
echo "Result from table..."$SQLRESULT
1 2180 10 2 2186 11 3 2198 12
So i was not getting how to loop through it...