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!

connecting Oracle 9i using perl cgi

Status
Not open for further replies.

rk68

Programmer
Jul 15, 2003
171
IN
Can I connect to Oracle 9i database using Perl CGI. If yes,
how do I do it ? I have tried the code which was available on a website, but that didn't help.

TIA
Raj
 
Thnks Philote for the link, but it didn't help.
I'm using Oracle 9i database along with Perl CGI ver 5.6 on an apache server. Its giving an internal server error while executing the script.
I have copied the script below. Please tell me if I written the correct code or is there a mistake. If so please revert.
============================
#!/usr/bin/perl

print "Content-type: text/html\n\n";

use CGI;
use DBI;
$query = new CGI;

print "<html><head></head>\n";
print<<"heading";
<body>
<table border=0 align=center>
heading

$sDataBaseSetName = 'DBI:Oracle:host=192.168.10.89; sid=dems; port=1521';
$sDataBaseName = 'dems';
$sUserName = 'demsuser';
$sUserPassword = 'demsuser';
$sDataBaseHandler = DBI->connect ( $sDataBaseSetName, 'demsuser', 'demsuser' ) ;

$qEquipmentDetailsSQL = "select per_person_no,per_login_id from dis.t_person_mst where rownum <= 15 " ;
$sDataBaseStringHandler = $sDataBaseHandler->prepare ( $qEquipmentDetailsSQL ) ;
print($qEquipmentDetailsSQL);
$sDataBaseStringHandler->execute ;
while ( @aEqpt = $sDataBaseStringHandler->fetchrow_array ) {
$person_no = $aEqpt[0];
$login_id = $aEqpt[1];
print"<tr><td>Person ---- $person_no</td><td> Login ----- $login_id</td></tr>\n";
}
print("</table></body></html>");
============================================

Thnks
Raj
 
Raj,

If you let us know what errors you're getting we might be able to provide guidance

--paul

cigless ...
 
This is error message in error log:

ORACLE_HOME environment variable not set!

DBI connect('host=192.168.10.89; sid=dems; port=1521','demsuser',...)
failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check ORACLE_HOME and NLS
settings etc. at /var/ line 15

Can't call method "prepare" on an undefined value at
/var/ line 17.
 
Where's your prepare statement? Line 17 of test4.cgi
Check all the values before going into the prepare statement, that is that each variable in the prepare has a value.

Print them to a file, or on screen

--Paul

cigless ...
 
hi Paul,
thnx for your reply. what abt this error?

ORACLE_HOME environment variable not set!

DBI connect('host=192.168.10.89; sid=dems; port=1521','demsuser',...)
failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check ORACLE_HOME and NLS
settings etc. at /var/ line 15

TIA
raj
 
raj,

did you get this sorted? sorry 4 not getting back.
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top