Oraperl $ora_errno problem with $ora_fetch.

Oraperl $ora_errno problem with $ora_fetch.

am 06.01.2007 00:37:22 von morrownb

I am having some issues with my company's upgrade of our Solaris 8
applications from Perl 5.00502/Oracle 8i to Perl 5.8.4/Oracle 10g

We have the following versions of Oraperl:

Under perl 5.00502:
Oraperl Emulation Interface version 1.37
Oracle Driver 0.59
DBI-1.02 Switch by Tim Bunce, version 1.02

Under perl 5.8.4, linked to 8i
Oraperl emulation interface version 1.44
DBD::Oracle 1.15 using OCI8 by Tim Bunce
DBI 1.42 by Tim Bunce

Under perl 5.8.4, linked to 10g:
Oraperl emulation interface version 1.44
DBD::Oracle 1.19 using OCI10.2.0.2 by Tim Bunce
DBI 1.42 by Tim Bunce

The problem is that the $ora_errno is not behaving as specified in the
documentation on CPAN. It states that $ora_errno is set to 0 as a special
case for ora_fetch() when it hits end of data, but in the two 5.8.4 versions
it does not set $ora_errno (it remains undef). My company has several
programs that depend upon a test like:

ora_fetch($csr)
if( defined($ora_errno) && $ora_errno == 0 ) {
#We have not found our record. Make loud noises.
}

There are several other instances in which the developers depend on the
ora_fetch behavior, because it worked fine under the older version. Can
anyone help me fix this without modifying all of our code?

____________________________________________________________ _____
Your Hotmail address already works to sign into Windows Live Messenger! Get
it now
http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/ ?href=http://get.live.com/messenger/overview

Re: Oraperl $ora_errno problem with $ora_fetch.

am 08.01.2007 00:58:58 von Tim.Bunce

Try this (untested):

--- oci8.c (revision 7883)
+++ oci8.c (working copy)
@@ -1672,6 +1672,9 @@
if (status == OCI_NO_DATA) {
dTHR; /* for DBIc_ACTIVE_off */
DBIc_ACTIVE_off(imp_sth); /* eg finish */
+ if (DBIc_COMPAT(imp_sth) && !SvOK(DBIc_ERR(imp_sth))) {
+ sv_setiv(DBIc_ERR(imp_sth), 0);
+ }
if (DBIS->debug >= 3)
PerlIO_printf(DBILOGFP, " dbd_st_fetch no-more-data\n");
return Nullav;

Tim.

On Fri, Jan 05, 2007 at 11:37:22PM +0000, Nathan Morrow wrote:
> I am having some issues with my company's upgrade of our Solaris 8
> applications from Perl 5.00502/Oracle 8i to Perl 5.8.4/Oracle 10g
>
> We have the following versions of Oraperl:
>
> Under perl 5.00502:
> Oraperl Emulation Interface version 1.37
> Oracle Driver 0.59
> DBI-1.02 Switch by Tim Bunce, version 1.02
>
> Under perl 5.8.4, linked to 8i
> Oraperl emulation interface version 1.44
> DBD::Oracle 1.15 using OCI8 by Tim Bunce
> DBI 1.42 by Tim Bunce
>
> Under perl 5.8.4, linked to 10g:
> Oraperl emulation interface version 1.44
> DBD::Oracle 1.19 using OCI10.2.0.2 by Tim Bunce
> DBI 1.42 by Tim Bunce
>
> The problem is that the $ora_errno is not behaving as specified in the
> documentation on CPAN. It states that $ora_errno is set to 0 as a special
> case for ora_fetch() when it hits end of data, but in the two 5.8.4
> versions it does not set $ora_errno (it remains undef). My company has
> several programs that depend upon a test like:
>
> ora_fetch($csr)
> if( defined($ora_errno) && $ora_errno == 0 ) {
> #We have not found our record. Make loud noises.
> }
>
> There are several other instances in which the developers depend on the
> ora_fetch behavior, because it worked fine under the older version. Can
> anyone help me fix this without modifying all of our code?
>
> ____________________________________________________________ _____
> Your Hotmail address already works to sign into Windows Live Messenger! Get
> it now
> http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/ ?href=http://get.live.com/messenger/overview

Re: Oraperl $ora_errno problem with $ora_fetch.

am 08.01.2007 22:46:09 von morrownb

Below are the test runs of the following script:

BEGIN SCRIPT test_fetch.pl
#!/usr/local/perl5.8.4/bin/perl -w
use Oraperl;
ora_version;
my $lda = ora_login('','','')
or die "Connect failed: $ora_errno, $ora_errstr"
;
$lda->debug(4);

my $select_stmt = q{select application from busndate where application =
'NOT_THERE'};
my $cursor = ora_open( $lda, $select_stmt )
or die "Couldn't open cursor: $ora_errno, $ora_errstr";
my @busndate_row = ora_fetch( $cursor );
print "We have data\n" if @busndate_row;
if ( defined($ora_errno) ) {
print "\$ora_errno is DEFINED\n";
print "\$ora_errno = $ora_errno\n";
}
else {
print "\$ora_errno is not defined.\n";
}
ora_close( $cursor );
ora_logoff( $lda );

END SCRIPT test_fetch.pl

NOTE: The original DBD::Oracle 1.19 interface behaves the same as before
(undef $ora_errno on end of data) when linked against Oracle 10.2.

****
****Test original Perl5.8.4 installed version
****
$ PERL5LIB= perl test_fetch.pl

Oraperl emulation interface version 1.44
DBD::Oracle 1.15 using OCI8 by Tim Bunce
DBI 1.42 by Tim Bunce

DBI::db=HASH(0x12f5f4) trace level set to 0x4/0 (DBI @ Ox0/0) in DBI
1.42-nothread (pid 27320)
-> prepare for DBD::Oracle::db (DBI::db=HASH(0x134880)~0x12f5f4 'select
application from busndate where application = 'NOT_THERE'')
dbih_setup_handle(DBI::st=HASH(0x12fb04)=>DBI::st=HASH(0x134 a54),
DBD::Oracle::st, 12fb10, Null!)
dbih_make_com(DBI::db=HASH(0x12f5f4), 12fd88, DBD::Oracle::st, 208, 0)
thr#0
dbd_st_prepare'd sql SELECT (pl1, al1, cs1)
dbd_describe SELECT (EXPLICIT, lb 80)...
fbh 1: 'APPLICATION' NO null , otype 1-> 5, dbsize 15/16,
p15.s0
dbd_describe'd 1 columns (row bytes: 15 max, 7 est avg, cache: 730)
<- prepare= DBI::st=HASH(0x12fb04) at Oraperl.pm line 122 via
test_fetch.pl line 10
-> FETCH for DBD::Oracle::st (DBI::st=HASH(0x134a54)~INNER
'NUM_OF_PARAMS')
.. FETCH DBI::st=HASH(0x134a54) 'NUM_OF_PARAMS' = 0 (cached)
<- FETCH= 0 at Oraperl.pm line 125 via test_fetch.pl line 10
-> execute for DBD::Oracle::st (DBI::st=HASH(0x12fb04)~0x134a54)
dbd_st_execute SELECT (out0, lob0)...
dbd_st_execute SELECT returned (SUCCESS, rpc0, fn4, out0)
<- execute= '0E0' at Oraperl.pm line 125 via test_fetch.pl line 10
-> ora_fetch
<- () [0 items]
$ora_errno is not defined.
-> finish for DBD::Oracle::st (DBI::st=HASH(0x12fb04)~0x134a54)
<- finish= 1 at test_fetch.pl line 21
-> disconnect for DBD::Oracle::db (DBI::db=HASH(0x134880)~0x12f5f4)
<- disconnect= 1 at Oraperl.pm line 105 via test_fetch.pl line 22
-> DESTROY for DBD::Oracle::st (DBI::st=HASH(0x134a54)~INNER)
<- DESTROY= undef
-> DESTROY for DBD::Oracle::db (DBI::db=HASH(0x12f5f4)~INNER)
<- DESTROY= undef

****
**** Test the new proposed version
****

$ PERL5LIB=/users/nmorro01/perl58lib/oracle8/lib/site_perl perl
test_fetch.pl

Oraperl emulation interface version 1.44
DBD::Oracle 1.19 using OCI8.1.7.0 by Tim Bunce
DBI 1.42 by Tim Bunce

DBI::db=HASH(0x12f2bc) trace level set to 0x4/0 (DBI @ Ox0/0) in DBI
1.42-nothread (pid 27353)
-> prepare for DBD::Oracle::db (DBI::db=HASH(0x29d5b0)~0x12f2bc 'select
application from busndate where application = 'NOT_THERE'')
dbih_setup_handle(DBI::st=HASH(0x12f864)=>DBI::st=HASH(0x29d 784),
DBD::Oracle::st, 12f870, Null!)
dbih_make_com(DBI::db=HASH(0x12f2bc), 12f6d0, DBD::Oracle::st, 216, 0)
thr#0
dbd_st_prepare'd sql SELECT (pl1, auto_lob1, check_sql1)
dbd_describe SELECT (EXPLICIT, lb 80)...
col 1: dbtype 1, scale 0, prec 15, nullok 0, name APPLICATION
: dbsize 15, char_used 0, char_size 0, csid 1, csform 1, disize 15
fbh 1: 'APPLICATION' NO null , otype 1-> 5, dbsize 15/16,
p15.s0
row cache OCI_ATTR_PREFETCH_ROWS 730, OCI_ATTR_PREFETCH_MEMORY 0
calling OCIAttrSet OCI_ATTR_CHARSET_FORM with csform=1
dbd_describe'd 1 columns (row bytes: 15 max, 7 est avg, cache: 730)
<- prepare= DBI::st=HASH(0x12f864) at Oraperl.pm line 118 via
test_fetch.pl line 10
-> FETCH for DBD::Oracle::st (DBI::st=HASH(0x29d784)~INNER
'NUM_OF_PARAMS')
.. FETCH DBI::st=HASH(0x29d784) 'NUM_OF_PARAMS' = 0 (cached)
<- FETCH= 0 at Oraperl.pm line 121 via test_fetch.pl line 10
-> execute for DBD::Oracle::st (DBI::st=HASH(0x12f864)~0x29d784)
dbd_st_execute SELECT (out0, lob0)...
dbd_st_execute SELECT returned (SUCCESS, rpc0, fn4, out0)
<- execute= '0E0' at Oraperl.pm line 121 via test_fetch.pl line 10
-> ora_fetch
<- () [0 items]
$ora_errno is DEFINED
$ora_errno = 0
!! warn: 0 CLEARED by call to finish method
-> finish for DBD::Oracle::st (DBI::st=HASH(0x12f864)~0x29d784)
<- finish= 1 at test_fetch.pl line 21
-> disconnect for DBD::Oracle::db (DBI::db=HASH(0x29d5b0)~0x12f2bc)
<- disconnect= 1 at Oraperl.pm line 101 via test_fetch.pl line 22
-> DESTROY for DBD::Oracle::st (DBI::st=HASH(0x29d784)~INNER)
<- DESTROY= undef
-> DESTROY for DBD::Oracle::db (DBI::db=HASH(0x12f2bc)~INNER)
<- DESTROY= undef




>From: Tim Bunce
>To: Nathan Morrow
>CC: dbi-users@perl.org
>Subject: Re: Oraperl $ora_errno problem with $ora_fetch.
>Date: Sun, 7 Jan 2007 23:58:58 +0000
>
>Try this (untested):
>
>--- oci8.c (revision 7883)
>+++ oci8.c (working copy)
>@@ -1672,6 +1672,9 @@
> if (status == OCI_NO_DATA) {
> dTHR; /* for DBIc_ACTIVE_off */
> DBIc_ACTIVE_off(imp_sth); /* eg finish */
>+ if (DBIc_COMPAT(imp_sth) && !SvOK(DBIc_ERR(imp_sth))) {
>+ sv_setiv(DBIc_ERR(imp_sth), 0);
>+ }
> if (DBIS->debug >= 3)
> PerlIO_printf(DBILOGFP, " dbd_st_fetch
>no-more-data\n");
> return Nullav;
>
>Tim.
>
>On Fri, Jan 05, 2007 at 11:37:22PM +0000, Nathan Morrow wrote:
> > I am having some issues with my company's upgrade of our Solaris 8
> > applications from Perl 5.00502/Oracle 8i to Perl 5.8.4/Oracle 10g
> >
> > We have the following versions of Oraperl:
> >
> > Under perl 5.00502:
> > Oraperl Emulation Interface version 1.37
> > Oracle Driver 0.59
> > DBI-1.02 Switch by Tim Bunce, version 1.02
> >
> > Under perl 5.8.4, linked to 8i
> > Oraperl emulation interface version 1.44
> > DBD::Oracle 1.15 using OCI8 by Tim Bunce
> > DBI 1.42 by Tim Bunce
> >
> > Under perl 5.8.4, linked to 10g:
> > Oraperl emulation interface version 1.44
> > DBD::Oracle 1.19 using OCI10.2.0.2 by Tim Bunce
> > DBI 1.42 by Tim Bunce
> >
> > The problem is that the $ora_errno is not behaving as specified in the
> > documentation on CPAN. It states that $ora_errno is set to 0 as a
>special
> > case for ora_fetch() when it hits end of data, but in the two 5.8.4
> > versions it does not set $ora_errno (it remains undef). My company has
> > several programs that depend upon a test like:
> >
> > ora_fetch($csr)
> > if( defined($ora_errno) && $ora_errno == 0 ) {
> > #We have not found our record. Make loud noises.
> > }
> >
> > There are several other instances in which the developers depend on the
> > ora_fetch behavior, because it worked fine under the older version. Can
> > anyone help me fix this without modifying all of our code?
> >
> > ____________________________________________________________ _____
> > Your Hotmail address already works to sign into Windows Live Messenger!
>Get
> > it now
> >
>http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01 /?href=http://get.live.com/messenger/overview

____________________________________________________________ _____
Dave vs. Carl: The Insignificant Championship Series.  Who will win?
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/ ?href=http://davevscarl.spaces.live.com/?icid=T001MSN38C0700 1

Re: Oraperl $ora_errno problem with $ora_fetch.

am 09.01.2007 12:57:39 von Tim.Bunce

On Mon, Jan 08, 2007 at 09:46:09PM +0000, Nathan Morrow wrote:
> Below are the test runs of the following script:
>
> **** Test the new proposed version

> -> ora_fetch
> <- () [0 items]
> $ora_errno is DEFINED
> $ora_errno = 0
> !! warn: 0 CLEARED by call to finish method
> -> finish for DBD::Oracle::st (DBI::st=HASH(0x12f864)~0x29d784)
> <- finish= 1 at test_fetch.pl line 21

Try this (also untested) in addition to the previous patch:

--- dbdimp.c (revision 7883)
+++ dbdimp.c (working copy)
@@ -2232,6 +2232,10 @@
if (DBIc_DBISTATE(imp_sth)->debug >= 6)
PerlIO_printf(DBIc_LOGPIO(imp_sth), " dbd_st_finish\n");

+ if (DBIc_COMPAT(imp_sth) && !SvOK(DBIc_ERR(imp_sth))) {
+ sv_setiv(DBIc_ERR(imp_sth), 0);
+ }
+
if (!DBIc_ACTIVE(imp_sth))
return 1;

Tim.