My bad. Either declare @data outside the if block or else process the array within the block. By having the 'my' inside it is localized and therefore you get no response.
-----Original Message-----
From: Ted Yu [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 14, 2005 1:54 PM
To: [email protected]
Subject: RE: Use DBI; vs. use Win32::ODBC;

I tried to print out the output of the select statement.  No error, but no printout either.  Not sure if there is an error in my code:
 
use Win32::ODBC;
my $pw = "password1";
my $user = "ted";
my $dsn = "db1";
$db = new Win32::ODBC("DSN=$dsn;UID=$user;PWD=$pw") || die "ERROR: Failed to open database $!\n" if(!$db);

my $sql="select count(*) from tblTicketFileProcessLog";
$db->Sql($sql);
 
if ($db->FetchRow())
{
    my @data = "">
}
else
{
    print "Query returned no results.\n";
}
print $data[0];


Peter Eisengrein <[EMAIL PROTECTED]> wrote:
 
 
 
What would be the code if i used Win32:ODBC?  The result of the select statement is a single value and not an array.  Appreciate your help, as I am new to using remote connections to a SQL database with Perl. 
 
 I have used it in a while loop and performed thousands of queries in the same session and have had no performance problems, although I'd believe the memory leak problem mentioned before.
 
 A similar call using Win32::ODBC would be:
 
 
my $dsn = "db_name";
$db = new Win32::ODBC("DSN=$dsn;UID=$user;PWD=$pw") || die "ERROR: Failed to open database $!\n" if(!$db);
 
my $sql="select count(*) from tblTicketFileProcessLog";
$db->Sql($sql);
 
if ($db->FetchRow())
{
    my @data = "">
}
else
{
    print "Query returned no results.\n";
}
 

 


This message was scanned by ATX
2:35:27 PM ET - 6/14/2005
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to