On Wed, 29 Jan 2003 00:28:07 +0100, you ("alex"
<[EMAIL PROTECTED]>) wrote:
>> while (my @row = $sth->fetchrow_array()) {
>> print join("\t", @row), "\n";
>> }
>i've tryed this... but it hasn't worked... i will re-try our...
>
>> my $sql = 'SELECT COUNT(*) FROM temp';
>yes - but this will result in a additional select and therefor more database
>activity :-(
>
>> my $i = 0;
>> while (my @row = $sth->fetchrow_array()) {
>> $i++;
>> }
>very difficult in my code... i will have a look if i can change the code.
>isn't it possible without a "while" ?
Shouldn't you look into "selectall_arrayref", then you would get all
rows as an arrayref, and each element of this is an arrayref to all
the columns returned.
my $aryref = $dbh->selectall_arrayref("SELECT * FROM temp");
if(!defined $aryref and !@$aryref) {
print "Nothing to show!\n";
die; # or preferbly something else
}
print scalar @$aryref, " rows found\n";
#The lines are:
foreach my $cols (@$aryref) {
print "Col:",join(";",@$cols),"\n";
}
# You might use map instead, but it is a sort of loop anyhow.
# Untested!
... and I usually do a map iterating over the col values to set undef
cols to ex. "" like:
my @cols = map {!defined($_) && $_ = '';$_} @$cols;
... still after memory, and untested!
--
mvh/Regards
K�re Olai Lindbach