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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can CGI works

Status
Not open for further replies.

Sameen

Technical User
Jul 13, 2002
1
PK
Hi Dears

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();


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


 
It has been a while since I played with Oracle, but I seem to remember having to set some environmental VARS in order for the Oracle connection to work. Sorry I can't be more help.

You might send a note to the DBI users list server....
dbi-users@perl.org

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top