problem to run sql startment in script

Hello,
I have a script to run a list of customer information, but it not work. can anyone help below:

echo "Please input list to check customer detail:"
read list
for file in 'cat $list.txt'
do
echo "select cuname as "FROM CUNAME", invo_num as "RECS", total_amount as "AMOUNT", tax_amount as "TAX", CUSTOMERNAME as "INTO CUSTOMER", status, original_amount from cuname_2 where CUNAMEin '$file' ;"|sqlplus4 >> output.txt
done

The list look like:
John
Marry
peter
tom

The script cannot read the list correctly.....:mad:

Thank you.

I think you have to escape all the quote characters inside the statement:

echo "select cuname as \"FROM CUNAME\", invo_num as \"RECS\", total_amount as \"AMOUNT\", tax_amount as \"TAX\", CUSTOMERNAME as \"INTO CUSTOMER\", status, original_amount from cuname_2 where CUNAMEin '$file' ;"|sqlplus4 >> output.txt

It's still not work.:mad:
nothing in the output.txt
If I just copy the startment below, it work ok.

echo "select cuname as \"FROM CUNAME\", invo_num as \"RECS\", total_amount as \"AMOUNT\", tax_amount as \"TAX\", CUSTOMERNAME as \"INTO CUSTOMER\", status, original_amount from cuname_2 where CUNAME in 'Tom';"|sqlplus4 >> output.txt

so, it look like cannot read the file correctly.

ANY HELP?????!!!:confused:

does the value in list variable read through "read statement"
contains another list of files or it just contain values ?

I will input the list filename.
For example: the filename is "customer.txt" and it contains the following:

Tom
John
Marry
Peter

anyone can help????

shouldn't this

for file in 'cat $list.txt'

be using BACK-quotes/ticks:

for file in `cat $list.txt`

Hi Happyv,

if you want use the oracle SQL query in shell script before that we have to connect the Oracle using sqlplus command with user name, password with respective oracle server host string.

Then you can use your query with appropriate format and you have to exit from sqlplus prompt using exit;

Reg,
Siva.P
Bangalore