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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: SQL Database Table to Perl Script

Replies are listed 'Best First'.
Re^3: SQL Database Table to Perl Script
by marto (Cardinal) on Oct 05, 2012 at 08:30 UTC

    "Sir...The script what I showed compiles. "

    Nope:

    C:\>perl -c 997371.pl Global symbol "$dbh" requires explicit package name at 997371.pl line +5. Global symbol "$dbh" requires explicit package name at 997371.pl line +6. Global symbol "$dbh" requires explicit package name at 997371.pl line +18. 997371.pl had compilation errors.

      Maybe this SQL will help.

      SELECT AccNum, max(date), Type, sum(Amount) FROM transaction GROUP BY + AccNum, Type union SELECT AccNum, max(date),'Balance', sum(if (type='Debit',-1*Amount,Amo +unt)) FROM transaction GROUP BY AccNum; SELECT * FROM transaction t where chequeno is not null or ddno is not +null;

      And this has little to do with perl this is an datbase question

        Sir.For the question below, I want to solve it with a single SQL query. I tried all possibilities but nothing is working. Please help: Query data from transaction table and calculate total amount debited by cheque, dd and by cash for each account.
      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;
    A reply falls below the community's threshold of quality. You may see it by logging in.
    A reply falls below the community's threshold of quality. You may see it by logging in.