problem in SQL query

I used the following code

code
select * from tablename where columnname

Instead of printing the expected output it prints all the files in the present directory since there is a "*" in the code. Is there any way to overcome the problem?

Thanks
Ananth

Ananth,

Assuming you are doing something like:

echo select * from table | sqlplus

or similar, you can escape the star with a backslash:

echo select \* from table | sqlplus

or quotes:

echo select '*' from table | sqlplus

Check the section on quoting in the manual page for your shell of choice

Why don't you put all between double quotes? Also, check SQLPlus' options: "-S" and "-L", they are usefull when using SQLPlus in scripts.

echo "select * from table" | sqlplus -S -L

There are also some other "tips" when doing database queries in scripts!

I hope it helps.