[ale] multiple query in DBD::mysql

Christopher Fowler cfowler at outpostsentinel.com
Fri Jul 18 08:10:07 EDT 2003




I'm trying to grab data from two tables and print
it out.  I'm generating a report.


     22 # Now retrieve data from the table.
     23 my $sth = $dbh->prepare("SELECT * FROM mantis_bug_table");
     24 $sth->execute();
     25 print "Number  Status       Summary\r\n";
     26 print "------- ------       -------------------------------------------------------\r\n";
     27 while (my $ref = $sth->fetchrow_hashref()) {
     28         my $status;
     29         if($ref->{status} == 10 ) {
     30             $status = "new";
     31         } elsif ($ref->{status} == 20 ) {
     32             $status = "feedback";
     33         } elsif ($ref->{status} == 30 ) {
     34             $status = "acknowledged";
     35         } elsif ($ref->{status} == 40) {
     36             $status = "confirmed";
     37         } elsif ($ref->{status} == 50) {
     38             $status = "assigned";
     39         } elsif ($ref->{status} == 80 ) {
     40             $status = "resolved";
     41         } elsif ($ref->{status} == 90) {
     42             $status = "closed";
     43         }
     44 
     45         my $dQuery = "SELECT * from mantis_bug_text_table where id like $ref->{id}";
     46         my $desc = $dbh->prepare($dQuery);
     47         $desc->execute();
     48 
     49         printf("%-7s %-12s %-50s\r\n", $ref->{id}, $status, $ref->{summary});
     50         while (my $r2 = $sth->fetchrow_hashref()) {
     51             printf("$r2->{description}\r\n");
     52         }
     53 }
     54 $sth->finish();


Error:
DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./list.pl line 27.
DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./list.pl line 27.

What is the best way to do this?

Thanks,
Chris
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list