my $sth = $dbh->prepare(q{
SELECT x, y, z FROM table1, table2
WHERE x = ?, y = ?
ORDER BY z
});
####
$dbh->do('delete from temp where x = ?', undef, $x);
####
$sth->execute;
$sth->bind_column(\$res);
$sth->fetch;
####
$sth->execute;
unless (@cols = $sth->fetchrow_array) {
# error
}