in reply to Problem with case in select statement

What database does it give errors with? That is important information to diagnose the failure. I know that SQL Server supports CASE statements (not surprising since it is based on Sybase). PostgreSQL also supports CASE. MySQL doesn't. I don't know about Oracle.

BTW, it is helpful to us and you if you format the SQL statement to make it more readable. I don't really like using indentation for SQL but always put each clause on a separate line. I tend to use here-docs to assign to a $sql variable and then prepare with the variable.

my $sql=<<END_HERE; SELECT foo FROM bar WHERE baz = ? END_HERE my $sth = $dbh->prepare($sql);