On Thu, 2003-10-23 at 14:42, Geoffrey Young wrote: > > You don't have to, but if you don't and the Oracle connection gets lost > > and Apache::DBI reconnects, your stale statement handles will all fail. > > The best thing to do is use prepare_cached. This will use an already > > prepared statement handle if possible. > > I haven't done any of this in a very long time, but last I remember the > results of using prepare_cached with Apache::DBI was undefined.
The prepare_cached code is very simple and easy to read. It tucks the statement handle into a hash. When it gets called again with the same SQL it checks the statement to see if it is still active and returns it if it is. Otherwise, it prepares a new statement. I've used prepare_cached with Apache::DBI for years and have never had any problems with it. Maybe you're thinking of how it used to die if you tried to reuse a statement handle without reading all of its results. This is typically caused by a programming mistake, but you can call finish() if you want to bail on a statement without reading it all, and it was changed from die to warn in DBI a couple of years ago. - Perrin