http://www.perlmonks.org?node_id=997422


in reply to Re^3: SQL Database Table to Perl Script
in thread SQL Database Table to Perl Script

Ok....This program:
#!/usr/bin/perl use DBI; use strict; use warnings; print "content-type:text/html\n\n"; my $dbh = DBI->connect('dbi:mysql:database:3306','prithvi','prithvi') +or die("Couldn't connect"); my $tran_cur = $dbh->prepare("SELECT AcNo, Type, SUM(Amount) FROM bank +tran GROUP BY AcNo, Type"); $tran_cur->execute; map {print "<td>$_</td>"}qw(Account Number-Type-Total Amount); print "<br/>"; while( my @data = $tran_cur->fetchrow_array) { my $rec = join ('-',@data); print "$rec<br/>"; } $tran_cur->finish; $dbh->disconnect;