in reply to Re: Perl/SQL Query
in thread Perl/SQL Query

Not to nitpick or anything, but that code is just so wrong. Your first statement dies, so the rest will not get executed, but if they were executed, the next statement prepares a SQL statement which does not do what I think you think it does. At least not portably (I'm not even sure it would work at all). If you want wildcards on either side of an argument, it is better done as:
my $sth = $dbh->prepare("select ... where column like ?"); my $rv = $sth->execute("%$argument%");
Also, methods are not interpolated inside quotes, so $error will not be set to what you think it should be. LIMIT is not portable (the OP didn't mention which database, so this at least is a nitpick). Lastly, $rv is only set to the number of rows affected on non-select statements. Some DBD's might set it to the number of rows selected (I remember a thread about DBD::SQLite recently where the behavior was changing), but that is not necessarily the case. The only reliable way to know the number of rows selected is to fetch and count each one.