I am using the DBI module to simply read a mysql database table and store columns into seperate arrays. The columns are storing identification codes. However, when i print the arrays within my perl script, one value has been missed out and placed later on in the array (which obviously messes the order of things up ;-( ).
The id that has been mis-placed (M57165208) looks out of place (as, although is contains chars and numbers, it is numerically higher that those before and after it). Can anyone suggest what is going on here and/ or an alternative solution that will preserve the database order within the per script?
Here is my code and a sample of the id's:
This is a sample of numbers from the database:my $sth21= $dbh->prepare(qq{SELECT MR_M FROM MR2}); die "Couldn't prepare queries; aborting" unless defined $sth21; $sth21->execute(); while (my @ary=$sth21->fetchrow_array()) { push @mr_m, @ary; } my $sth22= $dbh->prepare(qq{SELECT MR_R FROM MR2}); die "Couldn't prepare queries; aborting" unless defined $sth22; $sth22->execute(); while (my @ary=$sth22->fetchrow_array()) { push @mr_r, @ary; } # HERE I PRINT OUT WHAT I HAVE READ FROM THE DATABASE for (my $i=0; $i<@mr_m; $i++) { print "$mr_m[$i]\t $mr_r[$i]\n"; }
This is how they look when printed out:mysql> select * from MR2 limit 10; +-----------+--------+ | MR_M | MR_R | +-----------+--------+ | M13470333 | RL2591 | | M13470334 | RL2590 | | M13470335 | RL2588 | | M13470339 | RL4708 | | M13470341 | RL2584 | | M13470342 | RL2583 | | M57165208 | RL2582 | | M13470344 | RL2580 | | M13470345 | RL2579 | | M13470346 | RL2578 | +-----------+--------+ 10 rows in set (0.00 sec)
M13470333 RL2591 M13470334 RL2590 M13470335 RL2588 M13470339 RL4708 M13470341 RL2584 M13470342 RL2583 M13470344 RL2582 M13470345 RL2580 M13470346 RL2579 M13470347 RL2578
In reply to DBI fetchrow_array problems by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |