in reply to Errors from a simple Package

It seems to me that all of your connections and queries could be "centralized" using connect_cached and prepare_cached.

Replies are listed 'Best First'.
Re^2: Errors from a simple Package
by tel2 (Pilgrim) on Mar 17, 2011 at 22:14 UTC

    Hi runrig,

    Sorry - I don't follow.  What I mean by "centralised" is, putting them in a package, so that in general I'll just have a single command for each query in my main scripts.  It can get quite lengthy to do everything in the main scripts, especially when one includes writing the SQL command to a debug logfile.  Is that what you thought I meant?  If so, how do you think connect_cached and prepare_cached would help achieve that?  From looking at them in the DBI doco, it looks as if they are mainly for improving performance on some kinds of repeated connections/queries.

    Thanks.

      If you are repeating your queries (and that's what I thought you were trying to do because it's the only reason I could think of to try to share statement handles), then prepare_cached would help. If you want all calls to connect to get the same database handle, then connect_cached might help.

      And on another note, I have a suspicion that you do not Use strict and warnings, which you should be doing.

        Thanks runrig.