saibsk
asked on
Returning a single value from resultset in Perl DBI
My result set is going to return only one value from the database. I am connecting to the DB using perl dbi. How shd i fetch the value? Please advise.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use prepare/exectue/fetch as shown by bounsy, or you can just use one of the selectrow methods, which does all of these at once.
#Get data as array
my @record = $dbh->selectrow_array('SELECT ....');
#Get data as arrayref
my $record = $dbh->selectrow_arrayref('SELECT ....');
#Get data as hashref
my $record = $dbh->selectrow_hashref('SELECT ....');
Mike