bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

am trying to extract data from column. but am only getting the first lastname am not getting the reset. i only get john

+----------+ | lastname | +----------+ | john | | Doe | | Jones | | Smith | +----------+
my $sth = $dbh->selectrow_array("SELECT lastname FROM dbase"); $dbh->disconnect; #its ok with array @data = $sth1; print @data;

Replies are listed 'Best First'.
Re: extract column data
by Discipulus (Canon) on May 24, 2017 at 11:41 UTC
    you resolved your issue now..

    it is time to read one of the best nodes here around: DBI recipes

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: extract column data
by Corion (Patriarch) on May 24, 2017 at 11:39 UTC

    ->selectrow_array fetches only a single row.

    Better use ->fetchall_arrayref instead.

      i tried it but, i get cant locate object method fetchall_arrayref via package dbi::db

      i always get this error when i try to use fetchall_arrayref

      use DBI; my $host =""; my $db =""; my $usr =""; my $pwd =""; my $dbh = DBI->connect("DBI:mysql:$db:$host", $usr, $pwd, { AutoCommit => 0, RaiseError => 1, }) or die $DBI::errstr; my $sth = $dbh->fetchall_arrayref("SELECT lastname FROM dbase"); $dbh->disconnect; #its ok with array @data = $sth1; print @data;

        Maybe now is a good time to review DBI to see what methods can be called on which objects and what the sequence of when to call which is.

        If you are unable to modify your code to use ->fetchall_arrayref, consider reading the documentation for ->selectall_arrayref and using that method.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: extract column data
by hippo (Archbishop) on May 24, 2017 at 11:38 UTC
    am only getting the first lastname am not getting the reset

    That's what selectrow_array does. If you want to select more than one row consider using a different method such as selectall_array.