Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: SQL Database Table to Perl Script

by erix (Parson)
on Oct 05, 2012 at 07:44 UTC ( #997408=note: print w/replies, xml ) Need Help??

in reply to SQL Database Table to Perl Script

You say:

I am getting the exact output for this.

But how is that possible when the script doesn't compile?

Replies are listed 'Best First'.
Re^2: SQL Database Table to Perl Script
by prithviraj (Novice) on Oct 05, 2012 at 07:51 UTC
    Sir...The script what I showed compiles. I want the answer for the 2 new questions in the same method shown in the script. That means for the 2 new questions, I just have to change the SQL query in the script shown. I want your help for the query. Thats it.

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


      C:\>perl -c Global symbol "$dbh" requires explicit package name at line +5. Global symbol "$dbh" requires explicit package name at line +6. Global symbol "$dbh" requires explicit package name at line +18. 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

        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;
        + sign is displayed in 2 lines. When I did paste my program in the discussion box, it received like that. Take off that + sign and execute. You might be executing it in a different database. Put that database name and execute. You will get the o/p.
        Now can you give me the solution for this question please: Query data from transaction table and calculate total amount debited by cheque, dd and by cash for each account.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997408]
[hippo]: Hope everyone else is enjoying their lunch too.
[1nickt]: However, note that it takes between 2 and 4 hours for a tick to be able to start transmitting bacteria. So even if it has burrowed in and started eating, if you get it soon you should be OK.
[perldigious]: 1nickt: No more red meat! It would be more humane to just kill you, wouldn't it! :-)
[1nickt]: Just don't make it barf.
[1nickt]: perldigious that's exactly what my stepson says.
[1nickt]: the tick that can make you a vegetarian
[perldigious]: Your Mother: Yeah, I have a tool for ticks that I use (mostly on my dogs thankfully), but it's just a cheapo one I got from my vets office... it works pretty good though.
erix saw a tick in a natural history museum collected from the scrotum of the curator (it was removed)
[Your Mother]: The exhibit, the tick, or the scrotum?
[erix]: (the man is even a paleontologist )

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-05-24 13:12 GMT
Find Nodes?
    Voting Booth?