Let the DBI cache your handles
 
 
- Sometimes it's not easy to hold all your handles
- 
- e.g., library code to lookup values from the database
- 
 
- The prepare_cached() method
- 
- gives you a client side statement handle cache:
 
 sub lookup_foo {
 my ($dbh, $id) = @_;
 $sth = $dbh->prepare_cached("select foo from table where id=?");
 return $dbh->selectrow_array($sth, $id);
 }
 
- On later calls returns the previously cached handle
- 
- for the given statement text and any method attributes
 
- Can avoid the need for global statement handle variables
- 
- which can cause problems in some situations, see later