in reply to Getting Record Set via DBI into an Array of Arrays

Use
my @data = @{ fetchall_arrayref() };

to get the recordset as an array containing arrayrefs of rows. See DBI.

Replies are listed 'Best First'.
Re^2: Getting Record Set via DBI into an Array of Arrays
by ikegami (Patriarch) on Apr 13, 2009 at 14:03 UTC

    Aside from the missing object in the method call, that creates an array element per row. The OP wants an array element per column.

    I suppose you could fix it afterwards using something like

    use Algorithm::Loops qw( MapCar ); my @data = MapCar { [ @_ ] } @{ $sth->fetchall_arrayref() };

    Note that using selectall_arrayref saves you from calling execute and even prepare if you so desire.

    use Algorithm::Loops qw( MapCar ); my @data = MapCar { [ @_ ] } @{ $dbh->selectall_arrayref($sth_or_sql) };