I have a minor optimization suggestion.  Instead of this:

unless ($sth_routine_name) {
    #setup statement handle
}

Do this:

$sth_routine_name ||= $dbh->prepare(....);

If $sth_routine_name is already defined, the first half of the OR will be true
and the right half, the assignment, will not be evaluated.  Otherwise the right
half will be evaluated and you'll get a nice new shiny statement handle.  I'm
pretty sure this is more efficient than setting up the unless block.

Cheers,

Wes Sheldahl




Rob Ransbottom <[EMAIL PROTECTED]> on 09/13/2001 10:03:11
AM

To:   [EMAIL PROTECTED]
cc:    (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject:  Re: undef & NULL




In my modules, I will:

    my $sth_routine_name;
    sub routine_name{
     unless ($sth_routine_name) {
         #setup statement handle
     }
     #use statement with @_ params
    }

> > I could easily have 150 prep'd statement handles lying around.

> Might that number be reduced if you use placeholders more to make the
statements
> more generic?

No, it will only grow.


rob                     Live the dream.





Reply via email to