renu has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
My perl program includes the below line,
$ora_errstr="";
If i run the program following error is displayed, "Can't modify $DBI::&errstr special variable at Myprogram.pl line #"
But i don't want to remove "$ora_errstr="";" line from the program. Could you please help me out from this problem.
"They may only be read; a fatal error occurs if a program attempts to change them." is given in the DBD perldoc. The error shows the DBD module. But there was no error in my previous DBI and DBD version . Thanks in advance,
Ren"u.

Replies are listed 'Best First'.
Re: perl DBI special variable problem
by idle (Friar) on Apr 07, 2006 at 09:15 UTC
    It seems not related to $ora_errstr="", rather you have something like $DBI::errstr=$var in your code.
      $ora_errstr=""; and $DBI::errstr=""; give same error
        You can't set a value to a read-only variable, why are you trying?
        The error string for a given handle is reset at most DBI method calls, so you shouldn't need to reset it.
Re: perl DBI special variable problem
by derby (Abbot) on Apr 07, 2006 at 12:44 UTC

    I'm not a DBD::Oracle expert (but why should that stop me from commenting!). Looking at the doc and source for DBD::Oracle, I see no mention of $ora_errstr. Are you aliasing it somewhere in your code (*ora_errstr = $DBI::errstr)?

    -derby
Re: perl DBI special variable problem
by runrig (Abbot) on Apr 07, 2006 at 16:44 UTC
    ora_errstr is from oraperl. oraperl is perl with Oracle libraries compiled in from before the days of DBI and DBD::Oracle. If you use one (oraperl or DBI) you shouldn't need the other in the same program (and you should only need oraperl if you need to support legacy code). You shouldn't need to set the errstr in either, it is just something that is automatically set (sort of, see this) after an error. So you can print it (or something) after you detect an error.

    Update: Oraperl is also a compatibility module from DBD-Oracle (to make oraperl programs transparently use DBI) so $ora_errstr is likely an alias for $DBI::errstr. Previous comments that you shouldn't need to set the errstr still apply.

    Another update: Apparently Oraperl is no longer supported. I suggest transitioning to pure DBI.