Pages

Monday, March 18, 2013

Reading file and passing parameter to Oracle SQL to fetch the data.


#!/bin/sh
rm -r FinalDepInfo.txt
for row in `cat myDep.txt`
do

a=$(C:/oraclexe/app/oracle/product/10.2.0/server/BIN/sqlplus -s hr/magogate@XE <<QUERY
spool mytest.txt
select first_name, last_name, email
from employees
where department_id = $row;
spool off;
exit;
QUERY);
less mytest.txt >> FinalDepInfo.txt
done;


Reading file line by line

#!/bin/sh
while read line
do
    echo $line
done < FinalDepInfo.txt

No comments:

Post a Comment