in reply to How to use Perl DBI to select just on column of db

selectcol_arrayref is a database handle method, but it can take a statement handle instead of a SQL statement as an argument:
my $sth = $dbh->prepare("select val1 from tb11 where x=?"); ... $dbh->selectcol_arrayref($sth, undef, $x);
The second argument is the "attributes" hashref, which can cause the method to fetch more than one column, and/or select which column(s) are fetched. See the docs.

Replies are listed 'Best First'.
Re^2: How to use Perl DBI to select just on column of db
by lightoverhead (Pilgrim) on Mar 18, 2011 at 15:37 UTC
    Hi runrig, That's the one I wanted. I almost forget that "undef" trick.

    Thank you very much.