KSH Sqlplus problem

Hi,

trying this

===============================
Temp=`sqlplus -s user/passwd <<EOF
WHENEVER SQLERROR EXIT 1
set serverout on
set feedback off
set heading off
select nam from tabel1
where x=y;
EOF`

echo Temp>>$logfile

The select statement is wrong on purpose (the column doesn't exist)

The output I am getting is:

select nam from tabel1xyz.logbgt.out........etc....lots of filenames of the current directory....where x=y....ORA-XXX ERROR.

Also if I write the select statement as

select nam from tabel1 where x=y;

The output is

select nam from tabel1 where x=yxyz.logbgt.out........etc....lots of filenames of the current directory........ORA-XXX ERROR.

The garbage prints after the first newline I think.

This doesn't happens when the select statement is corrected.

Will appreciate any hint on this behavior ..thanks..

Amit

If the slect statement is wrong, then correct it.

I don't use sqlplus, so I don't know what it takes to correct it, but the correct way to write the shell command is:

Temp=`sqlplus -s user/passwd` <<EOF
WHENEVER SQLERROR EXIT 1
set serverout on
set feedback off
set heading off
select nam from tabel1
where x=y;
EOF

Hi ,

Looks like I foud the fix...

I case of an error in the select statement sqlplus puts a * below the column name.. and unix expands this wildcard, listing all the filenames.

to fix this ....
quote the variable and stop the wilcard expansion.

echo "$Temp"

thats it..

Thanks
Amit