in reply to Code useless, forget it... this is more usefull (o;
in thread prepare_cached for DBI::Oracle

OK, I see nothing obviously wrong in this snippet, but...
(Apologies if this is teaching you to suck eggs)

1. If your main concern is overall speed, I suggest some detailed profiling. Find where the code is spending most of its time. See Benchmark. Use the Benchmark->new and timediff() methods to look at checkpoints. Since you are doing lots of logging anyway, have your loggit() call put a timestamp in the LOG.

2. Have you turned on the error checking in the DB ?

{RaiseError=>1}
in the connect(). It could be that there is a problem in the prepare() line.

3. Is it only failing if you use prepare_cached ? I.E. does it work without the _cached ?

4. Are you using the $sth->finish() when no longer needed ? This can generate errors if there is an open execute and _cached is called again.

That's all I can think of right now, good luck.
--
Brovnik

Replies are listed 'Best First'.
Re: Re: Code useless, forget it... this is more usefull (o;
by Eric.D (Initiate) on Jun 22, 2001 at 17:34 UTC
  • How about using a LIMIT command ...
    unfortunately, LIMIT is not valid in ORACLE )o; and I call both of the one I detail about 80 000 times...
  • I tried to bind the values.. same problem...
    $sth_imei = $dbh->prepare_cached(<<__EOSQL__) or die "Couldn't parse q +uery:".$sth_imei->errstr; SELECT imei FROM imei_period WHERE (mobile_number = :mob) AND (account_no = :acc) __EOSQL__ $sth_imei->bind_param( ':mob', $rec[1] ); $sth_imei->bind_param( ':acc', $rec[0] ); $sth_imei->execute() or die "Couldn't execute query:" . $sth_imei- +>errstr; @imei = $sth_imei->fetchrow_array; print "IMEI : @imei\n";
    When executed, the $sth_imei->errstr does not return anything...
    I check, the SQL works and return the requested infor if executed in SQLPlus...

    This is very frustrating, especially since the $sth_acc one is working fine...
  • for $sth->finish() I thought I should not use it as it was cached ??
    But yes, I do not use it much...
  • Ihad the PrintError => 1, set, but not the RaiseError one.
    If I use RaiseError => 1 it doesnot change a thing )o; still no error reported...

    I will go for a perl -w I think... (o;
      A couple more ideas (sparked by the 80,000) :
      1. Try binding the return values. e.g.
        my $imei; $rc = $sth_imei->bind_col(0,\$imei); $sth_imei->execute(); $sth_imei->fetch(); print "IMEI : $imei\n";
      2. If you don't want to do that, at least use ->fetchrow_arrayref(). Otherwise, each execute call has to create a new list for you. The _arrayref gives you a ref. to a static array, so less copying.
      3. bind_param should take a colum number shouldn't it, not a name, e.g. $sth_imei->bind_param(0,$rec[1])
      Either of the first 2 should save time, given 80,000 iterations.
      Finally, note that execute() can return '0E0' meaning 0 but true, meaning no rows (and different to undef for errors). May be worth checking for that explicitly.
      I think I'm out of ideas now...
      --
      Brovnik
Re: Re: Code useless, forget it... this is more usefull (o;
by Eric.D (Initiate) on Jun 22, 2001 at 18:32 UTC
    3. Without the "_cached", it does not seems to change anything.....

    I used DBI->trace as Arguile wisely suggested, and it looks like all is fine... strange...
    The Statement is prepared, the parameter binded, and the all thing is executed successfully.
    BUT it returns nothing ([0] items).

    if I cut and paste the SQL from the Perl, and replace the :mob and :acc by the binded values in the log file, it returns the value fine (the entrie does exist in the table...).

    Maybe I look for an error in the Perl when I should go and seek the wisdom of the DBA Administrator as he might have error log of my activities....