TIA!

Has anybody authenticated via web/Apache/DBI with Oracle?

Thanks for tips to unclutter script & change error out call.
I've also remove "my" from connect sequence ( my idea to further simplify).
I've enclosed entire brief script to make clear my point.

Problem restated: script fails at "test 3" print ( ie, when authenticating) 
when called
from browser ( ie , does not authenticate). statement  "test 1" through "test 
3" do 
print in browser, indicating web environ is correct.  Moreover, It runs fully 
without 
error when executed from the NT shell command prompt ( ie, outside of
browser/CGI ).

How does one  connect to Oracle "TNS service layer" (as suggested).  No DBI 
examples ever appear that way in DBI docs ( that I've seen).  Docs always
use oracle SID.   Please provide example change to script calling "TNS 
service" 
(if you know this method does work at least as well as calling SID. 
I've followed Oracle examples in DBI Perl book ( which is to call SID & this 
all works from command shell).

What is meant by the advice to "set env variables for web server"? Which 
variables.
Reminder:  the script does print "test1,test2,test3" in browser when called 
from browser so that whole Apache cgi-bin setup is to some degree correct.

Goal:  to get this "select" output ( after authenticating via web) to print
in browser.  

What works:  The script works fully from NT  command shell.

Problem: the script does not authenticate when called from browser.

Confusion:  No error in Apache web "error" log or any error in Oracle *.trc 
logs
 to debug authentication problem.

***********
full script...
**********
#!d:/perl/bin/perl.exe -w
print "Content-type: text/html\r\n\r\n";
use CGI;
use DBI;
use DBD::Oracle;

print " test1 ";
print " test2 ";

%attr = (
 PrintError => 0,
 RaiseError => 1
);

print " test3 ";
$dbh = DBI->connect("dbi:Oracle:orat1", "system", "manager", \%attr )
   or die "cant connect: , $dbh->errstr(), \n";
print " test4 ";

$dbh->trace(3, "dbitrace.log");
$query="SELECT A_ID FROM e_code";

$sth = $dbh->prepare($query);
$sth->execute;

while (( $A_ID) = $sth->fetchrow() ) {
print "$A_ID\n";

}
$sth->finish;
$dbh->disconnect
     or die "Disconnect failed: $dbh->errstr()";
exit;
****************
end entire script
*******************

>> Please don't set env variables inside script). Setting environment var's 
>> isnt one of the functionalities of your script. Make sure they are set for
>>  the webserver before your script is executed. Is see you are connecting by
>> SID. You might wanna trie connecting to the TNS service layer instead,

> Have a test which executes & fine on command line but
> same script stops @ connect line when run as cgi
>  via browser.
 
>> Did you check the error log of the webserver? Might be that your script 
dies
>> on the connect statement.
 
 > }
 >       foreach $key (keys %ENV) {
 >       print "$key --> $ENV{$key}";
 > }
 >
 > foreach $dir (@INC) {
 > print "$dir\n"
 > }
 > print "\n test11 \n<\H2>";
 > %attr = (
 >  PrintError => 0,
 >  RaiseError => 1
 > );
 > my $dbh = DBI->connect("dbi:Oracle:orat1", "system", "manager", \%attr )
 >     or die "cant connect: , $dbi::errstr(), \n";
 
>> I think this is where your script dies!
>> Check STDERR (e.g. webservers error_log for details).
>> By the way, you wont get the error returned by dbi in this way, because the
>> double colon wont be resolved in strings. Besides you are calling the 
errstr
>> method on an instance as a class method. Better use $dbh->errstr(). This
>> might not contain an error message in this case, because the conenction
>> failed and $dbd might not point to an object.
 

Reply via email to