CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
ODBC

 



brennanmt
Deleted

Mar 29, 2001, 10:19 AM

Post #1 of 4 (313 views)
ODBC Can't Post

I'm writing a program that returns a query from a database. I'm looking for the sum of the total cost of items belonging to a specific owner. How do I actually display that information to list the owner and the sum?



Jasmine
Administrator

Mar 29, 2001, 11:38 AM

Post #2 of 4 (310 views)
Re: ODBC [In reply to] Can't Post

Not sure I'm understanding your questions. You have already successfully queried the db... where are the results? Where do you want it to output to?



brennanmt
Deleted

Mar 29, 2001, 1:07 PM

Post #3 of 4 (309 views)
Re: ODBC [In reply to] Can't Post

Here's the code I'm using. The problem is that I can't seem to get the individual organazation and the sum of the cost to print out properly. Can you see what I'ved missed?

use Win32::ODBC;
$DSN="battery";
$table="batterytrackingtable";
my $mydb = Win32::ODBC->new($DSN);
$SQL = qq|Select Organization SUM( Cost) From $table |;


if (! $mydb){
print "error connecting to database";
Win32::ODBC::DumpError();
die;
}

if ($mydb->Sql($SQL)){
print "Error getting info from Database";
$mydb->DumpError();
}
while ($mydb->FetchRow()){
Úta=$mydb->DataHash;
print "$data{ tion} $data{ Year} $data{ Cost}\n";
}

$mydb->Close();




brennanmt
Deleted

Apr 3, 2001, 9:54 AM

Post #4 of 4 (295 views)
Re: ODBC [In reply to] Can't Post

I figured out the problem. I was trying to do too much with a single Sql statement. I just used two, and it worked fine.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives