Can't call method "Sql"... need help



hello,

I have a problem CGI script. I am really sorry, this looks quite
big...

I created a package pkg::fetch_history.pm and placed it in c:\Perl
\lib. Then I created a perl file to run from the commad promt. the
program executed well without fail. The code is as follows,

#!C:\Perl\bin\perl.exe
use pkg::fetch_history;

@dates = pkg::fetch_history::get_Dates();
foreach $d (@dates)
{ print "\n",$d; }

the data base exists locally.

Then I created cgi script to populate the values into combo box, it
says

Can't call method "Sql" on an undefined value at C:/Perl/lib/pkg/
fetch_history.pm line 20.

I am not sure why is this. Below is the fetch_history.pm and
combobox.cgi script.

-----------------------------------------------------------------------------------------------
#!C:\Perl\bin\perl.exe

# this is fetch_history.pm

package pkg::fetch_history;
use strict;
use Win32::ODBC;

my $db = new Win32::ODBC('ServerStatistics'); #ODBC driver object
#if (!$db)
#{
# print "Database could not be found\n";
#}

sub get_Dates
{
my $q = "select distinct(build_date) from wdf_history order by
build_date";
$db->Sql($q);
my @dates;
push(@dates, $db->Data()) while($db->FetchRow);

return @dates;
}
---------------------------------------------------------------------
#!C:\Perl\bin\perl.exe

use CGI::Carp qw(fatalsToBrowser);
use CGI;
use pkg::fetch_history;

$cgi = new CGI;
print $cgi->header;

@dates = pkg::fetch_history::get_Dates();
print "here is the dates value",@dates;
print <<ENDHTML;
<html>
<head><title> Server statistics </title></head>
<body>
<select name="menu">
ENDHTML


foreach my $d(@datest)
{
print <<ENDHTML;
<option value="$d" selected>(please select:)</option>
<option value="$d">$d</option>
ENDHTML

}
------------------------------------------------------------------



Am I wrong some where?


Thank you,
Regards,
kath.

.



Relevant Pages

  • dynamic lib ignored even after "found" in "install_driver(Oracle) failed: Cant load..." cgi problem
    ... here's a problem it seems a lot of people are seeing when running a CGI script ... after installing the the sqlplus client on my linux machine (and testing it on the command line, successfully connecting to our oracle db), and then installing the perl moduleneeded to make connections in perl scripts and cgis, i find, like so many others i've seen complain about this, that my cgi script runs fine from the command line, but fails when it is run as a CGI via my machine's apache webserver. ...
    (perl.dbi.users)
  • Re: a short non-working Perl script
    ... and learn the *right* way to write a CGI script in Perl. ... A minor niggle - Perl does not seem to match END_OF_PART2 unless I ... Those four should be in EVERY Perl CGI script you write. ... Get rid of this entire mess and replace with: ...
    (comp.lang.perl.misc)
  • Re: CGI POST problem was: How to read POSTed data
    ... >> how is a multipart POST request parsed by CGIHTTPServer? ... > is passed to the CGI script, which can choose to parse it or not using ... So I have to use that instead of FieldStorage? ...
    (comp.lang.python)
  • RE: Apache, Oracle, Perl DBI Problems
    ... Did you try executing your Perl CGI script from the command line (as ... maybe it's an Apache setup thing rather than a DBI thing. ...
    (perl.dbi.users)
  • Re: How to call an internal CGI subroutine?
    ... > How are subroutines called within a single CGI script? ... > ...etc closing html stuff ... > sub someroutine { ...
    (comp.lang.perl.misc)