The following SQL select statement worked at the sqlplus command line:
select A.NAME, B.IMAGE from ATABLE A, BTABLE B where A.WKEY = B.WKEY and A.NAME='AMANDA';

But from a script I got an ORA-00904 error.

Here's a partial code:

$sql = "set linesize 10000;\n";
$sql .= "set pagesize 0;\n";
$sql .= "select A.NAME, B.IMAGE from ATABLE A, BTABLE B where A.WKEY = B.WKEY and A.NAME='AMANDA';";

$command = "echo '$sqlplus' | sqlplus -S " . $hostLogin;

open(QUERY, "$command 2>&1 |");

while ($line = <QUERY>)
{
chomp($line);
last if length($line) == 0;
push @AllData, $line;
}
close(QUERY);


Also, It works if I remove .... and A.NAME='AMANDA' from the last $sql.

Any assistance would be appreciated thanks. I just need a fresh eye just I spent the last couple hours loking at this and can't seem to solve it.
--DRM