I am trying to pass the select statement as a variable, depending on which type of 
access someone has, but I get an error:


DBD::Oracle::db prepare failed: ORA-00900: invalid SQL statement (DBD: error possibly 
near <*> indicator at char 1 in '<*>'Select a.prty, a.mess, a.cdat, a.suno, a.alrt 
from alerts a where a.dnst = 2 order by a.prty, a.cdat DESC'') at 
d:\Inetpub\wwwroot\smi\alerts.pl line 107.

Line number 107 is noted in my code below.

my $sql;
my $sth = "";
if ($accs eq 4){
$sql = "Select a.prty, a.mess, a.cdat, a.suno, a.alrt from alerts a where a.dnst = 2 
order by a.prty, a.cdat DESC";
}
elsif ($accs eq 2){
$sql = "Select a.prty, a.mess, a.cdat, a.suno, a.alrt from alerts a where a.spst = 2 
and a.suno = '$suno' order by a.prty, a.cdat DESC";
}
*107 - my $sth = $dbh->prepare('$sql') or die "Error in prepare";
$sth->execute or die "Error in execute";

Any help is appreciated!



Reply via email to