The code I am using requires foreknowledge of the amount of results to be outtputted.There's a bunch of ways you could do this, but they mostly depend on how you'll be outputting your data. If you're just listing what you got out of the database you could just do this
Or if you're not too concerned about the field names you could just print out all the values like sowhile(my $rr = $sth->fetchrow_hashref()) { print "$_: $rr->{$_}\n" for keys %$rr; }
Or if you want a list of enumerated the valueswhile(my @rows = $sth->fetchrow_array()) { print "Values: @rows\n"; }
So as you can see you have plenty of options. Personally I'd recommend using the fetchrow_hashref() method as the brain maps better to names than sequences. See the DBI docs for more info on the methods mentioned above.while(my @rows = $sth->fetchrow_array()) { print "$_: $rows\n" for @rows; }
_________
broquaint
In reply to Re: Re: Creating Dynamic SQL statements using arrays
by broquaint
in thread Creating Dynamic SQL statements using arrays
by johnirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |