iis and dbi

J

John Giblin

Hi,

I am making a simple program that connects to Oracle and then display the
results. When I exec the program via command like, there does not seem to
be a problem. When I do it through a browser I do not get any print commands
past the connection

here is what I have:
use strict;
use DBI;

my ($dbh, $sth, @row);
my %attr = (
PrintError => 0,
RaiseError => 0,
);
$ENV{"ORACLE_HOME"}="F:/oracle/ora92";


print "Content-type:text/html\n\n";
print <<HEADER;
<HTML>
<HEAD>
<TITLE>A Test Page</TITLE>
</HEAD>
<BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
<P>
HEADER


print "Connecting to DB..<br>\n";
$dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
or die "Can't connect to database: $DBI::errstr\n";
print "Connected<br>\n";
print "Create sql statement<br>\n";


$sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
or die "Can't prepare SQL statement: $DBI::errstr\n";

print "Exec sql statement<br>\n";

$sth->execute
or die "Can't execute SQL statement: $DBI::errstr\n";

### Retrieve the returned rows of data
while ( my @row = $sth->fetchrow_array() ) {
print "Row: @row\n";
}

warn "Data fetching terminated early by error: $DBI::errstr\n"
if $DBI::err;


$dbh->disconnect();

Results in a browser:
Connecting to DB..
 
M

Michael Budash

John Giblin said:
Hi,

I am making a simple program that connects to Oracle and then display the
results. When I exec the program via command like, there does not seem to
be a problem. When I do it through a browser I do not get any print commands
past the connection

here is what I have:
use strict;
use DBI;

my ($dbh, $sth, @row);
my %attr = (
PrintError => 0,
RaiseError => 0,
);
$ENV{"ORACLE_HOME"}="F:/oracle/ora92";


print "Content-type:text/html\n\n";
print <<HEADER;
<HTML>
<HEAD>
<TITLE>A Test Page</TITLE>
</HEAD>
<BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
<P>
HEADER


print "Connecting to DB..<br>\n";
$dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
or die "Can't connect to database: $DBI::errstr\n";
print "Connected<br>\n";
print "Create sql statement<br>\n";


$sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
or die "Can't prepare SQL statement: $DBI::errstr\n";

print "Exec sql statement<br>\n";

$sth->execute
or die "Can't execute SQL statement: $DBI::errstr\n";

### Retrieve the returned rows of data
while ( my @row = $sth->fetchrow_array() ) {
print "Row: @row\n";
}

warn "Data fetching terminated early by error: $DBI::errstr\n"
if $DBI::err;


$dbh->disconnect();

Results in a browser:
Connecting to DB..

try:

use strict;
use DBI;
use CGI::Carp qw/fatalsToBrowser/;

my ($dbh, $sth, @row);
my %attr = (
PrintError => 1,
RaiseError => 1,
);

etc.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top