Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Perl Database script to Spreadsheet script [closed]
- TranID Date AccNum Type Amount ChequeNo DDNo
- 657520 02-07-1999 0181432 Debit 16000 465774
- 657524 02-07-1999 0181432 Debit 13000 569086
- 657538 09-07-1999 0181432 Credit 11000
- 657548 18-07-1999 0181432 Credit 15500
- 657519 02-07-1999 0181432 Debit 12000
- 657523 02-07-1999 0181432 Credit 11000
- 657529 03-07-1999 0181433 Debit 15000 466777
- 657539 10-07-1999 0181433 Credit 10000
- 657541 11-07-1999 0181433 Debit 12000
- 657525 03-07-1999 0181433 Debit 15000 569999
- 657533 05-07-1999 0181433 Credit 12500
- #!/usr/bin/perl
- use strict;
- use warnings;
- use DBI;
- print "content-type:text/htmlnn";
- my $dbh = DBI->connect('dbi:mysql:database:3306','prithvi','prithvi')
- or die "Couldn't connect";
- my $tran_cur = $dbh->prepare("SQL Query");
- $tran_cur->execute;
- map { print "<td>$_</td>" } qw(AccountNumber-ChequeDebit-DDDebit-CashDebit);
- print "<br/>";
- while (my @data = $tran_cur->fetchrow_array()) {
- my $rec = join '-', @data;
- print "$rec<br/>";
- }
- $tran_cur->finish;
- $dbh->disconnect;
- AccountNumber-ChequeDebit-DDDebit-CashDebit
- 0181432-16000-13000-12000
- 0181433-15000-15000-12000
- #!/usr/bin/perl
- use strict;
- use warnings;
- use DBI;
- print "content-type:text/htmlnn";
- my $dbh = DBI->connect('dbi:mysql:database:3306','prithvi','prithvi')
- or die "Couldn't connect";
- my $tran_cur = $dbh->prepare("
- SELECT `AccNum`, `Amount`
- FROM `database`
- WHERE `Type` = 'Debit'
- ORDER BY `TranID`;
- ");
- $tran_cur->execute;
- print "<br>AccountNumber-ChequeDebit-DDDebit-CashDebit</br>n";
- my %h;
- while (my @data = $tran_cur->fetchrow_array()) {
- if ($h{$data[0]}) {
- $h{$data[0]} .= "-$data[1]";
- }
- else {
- $h{$data[0]} = $data[1];
- }
- }
- $tran_cur->finish;
- $dbh->disconnect;
- foreach my $key (sort keys(%h)) {
- print "<td>$key" . "-" . $h{$key} . "</td>n";
- }
Add Comment
Please, Sign In to add comment