Please place <code> tags around your code. It makes it much easier to read, and your square brackets will be properly escaped.
Also, use placeholders in your SQL, like this:
my $sql="Select Count(*) From ClearTransferData Where AccountNo = ? and TransferFlag = ? and TransferType = ? and RejectType = ? and AdpNumber = ? and Shares = ? and ProcessingDate = ? "; my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute(@data); # Fetch results with $sth->fetchrow_array(), or whatever $sth->disconnect();
This is safer (since it will automagicaly escape naughty database characters), might be faster (depending on your database and the specifics of what you're doing), and is better if you end up using $dbh->prepare_cached->($sql) instead (since the data isn't contain in the SQL, the same statement can be refetched with less performance hit, even when the data chages).
$dbh->do() is for very simple cases (like SELECT COUNT(*) FROM some_table). You don't have a simple case.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
In reply to Re: Select Count(*) result
by hardburn
in thread Select Count(*) result
by SQLMan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |