DBI Prepare Issue

Posted by b_kannan on 2006-11-22 02:06

Hi all,

I am using the following code to connect to the oracle database and select/fetch a data.

The problem is the the below code works fine in Command Prompt.
But when the same code is run in the HTML Browser the statement seems to halt before the prepare statement.

Client Machine:
Windows 2000 with IIS + Active Perl (latest version)
Using DBI:Oracle
Using Oracle Instant Client for 10g 10.2
Using ODBC OracleClientInstant

Server Machine:
Windows 2003 Server
Oracle 10g 10.2 Standard which is reachable using the ODBC Administrator

I tried both the direct host connection as well as ODBC System DSN. In both only the command prompt mode works but not the HTML.

######### Code Start #############
use strict;
print "Content-type: text/html\n\n";
print "Debug:Perl Oracle Code Starting.\n";
use CGI qw( :standard );
use DBI;

print "Debug:Perl to Oracle: Initiating Connection.\n";
my $dbh = DBI->connect("dbi:Oracle:host=xxx.xxx.xxx.xxx;sid=xxx;port=xxxx", "xxxx", "xxxx");
print "Debug:Perl to Oracle: Connected.\n";

print "Debug:Perl Query Starting.\n";
my $sth = $dbh->prepare("SELECT TNAME, TABTYPE FROM TAB");
$sth->execute();

my ($tname, $tabtype); # Declare columns
$sth->bind_columns(undef, \$tname, \$tabtype);

while ($sth->fetch())
{
print "Object: $tname, type: $tabtype\n";
}
$sth->finish(); # Close cursor
print "Debug:Perl Query End.\n";

print "Debug:Perl Oracle Code Ending.\n";

######### Code End ###############

######### Output through Command Prompt ########
Content-type: text/html

Debug:Perl Oracle Code Starting.
Debug:Perl to Oracle: Initiating Connection.
Debug:Perl to Oracle: Connected.
Debug:Perl Query Starting.
Object: USERLINKS, type: TABLE
Object: SUB_LINKS, type: TABLE
Object: USER_AUTHENTICATION, type: TABLE
Debug:Perl Query End.
Debug:Perl Oracle Code Ending.
######### End of Output through Command Prompt ########

######### Output through WEB HTML ########
Debug:Perl Oracle Code Starting. Debug:Perl to Oracle: Initiating Connection. Debug:Perl to Oracle: Connected. Debug:Perl Query Starting.
######### End of Output through WEB HTML ########

Note: In Output through WEB HTML the statement after
my $sth = $dbh->prepare("SELECT TNAME, TABTYPE FROM TAB");
is not execute.

Please help me.

Regards,
Kannan.B