Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Oracle CGI

Status
Not open for further replies.

himash

Programmer
Joined
Jul 12, 2002
Messages
2
Location
PK

I'm facing problem to access Oracle Data through Internet Browser
Using
Perl, Oracle9i, DBD::ORACLE
On
Linux 7.1

----------------------------------------------------------------------------------
This is Perl Code To Fetch data from Oracle9i Using DBD::ORACLE

and works FINE at Command Line

----------------------------------------------------------------------------------
#!/usr/bin/perl

use strict;

use DBI;

use warnings;


my $dbh = DBI->connect('dbi:Oracle:sunora', 'scott','tiger') || die "Not Connected";



print "Test Perl On Sun";


my $sql = qq{ SELECT empno, ename ,deptno , sal FROM emp};

my $sth = $dbh->prepare($sql);


$sth->execute();


my ($tname);

my ($tno);

my ($dept);

my ($sala);


$sth->bind_columns(undef, \$tno, \$tname ,\$dept ,\$sala);

print "List Of Employees:\n\n";


while($sth->fetch())

{

print "$tno $tname $dept $sala\n";

}

$sth->finish();

$dbh->disconnect;


------------------------------------------------------------------------------------

But when i generate CGI, It returns nothing.

-----------------------------------------------------------------------------------


#!/usr/bin/perl

use strict;

use DBI;

use CGI;

use warnings;




my $cg = new CGI;


print $cg->header();

print $cg->start_html("Welcome");


my $dbh = DBI->connect('dbi:Oracle:sunora',
'scott','tiger') || die "Not Connected";



print $cg->b("Hello Oracle");

my $sql = qq{ SELECT empno, ename ,deptno , sal FROM emp};


my $sth = $dbh->prepare($sql);

$sth->execute();


my ($tname);

my ($tno);

my ($dept);

my ($sala);


$sth->bind_columns(undef, \$tno, \$tname ,\$dept ,\$sala);


print $cg->b("List Of Employees");


while($sth->fetch())

{

print $cg->b("$tno $tname $dept $sala");

}

$sth->finish();

$dbh->disconnect;

print $cg->end_html();


-----------------------------------------------------------------------------------------


 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top