Hi,
You are trying to mix and match a here document and normal shell commands, which is not possible (the shell/sql won't be able to figure out which is which).
Have a look at the following:
Code:
#!/bin/bash
cat logcountOP | \
while read TblName RCDummy
do
echo -n "${TblName} : "
sqlplus -s sa/sa@conCRM5 <<SQLScript
set heading off feedback off pagesize 0 linesize 30000 trimout on;
select count(*) from ${TblName};
SQLScript
done > DBcountOP
I'm assuming that the
set heading off .... line is needed and doesn't generate output.
If you use 2 variables after the while read, those are filled with the first and second field from the logcountOP file. This way there is no need for a cut command.
The
echo -n "${TblName} : " echo's the table name, the -n makes sure there is no carriage return.
Everything in the here document (all between <<SQLScript and SQLScript) is given to sql.
Hope this helps.
EDIT:
If you have a very large number of tables that need to be checked, this approach might not be what you want. The above example will open and close a sql session for every table that needs to be checked.
Creating a sql file which holds all the sql commands and giving this to sql would be a better solution, but also a bit harder to implement.