RE: Memoizing non-place-holding sql statements to place-holding
I've read DBI doc but I cann't understand prepare_cached.
Any difference between prepare and prepare_cached?
prepare_cached is useful if you are going to re-use
a statement handle. It stores the statement handle
in a hash keyed by the sql statement itself. This
saves re-preparing the statement if it is reused:
For example:
my $sth = $dbh->prepare_cached( 'select foo from bar' );
Calls code like:
my $dbh = shfit;
my $sql = shift;
...
$cached_statments{ $sql } ||= $dbh->prepare( $sql );
This only does the prepare once (when the ||= finds a
false value in %prepared_statements).
These are useful when you are going to re-run the same
query any number of times from different parts of the
code.
--
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark@xxxxxxxxxxx 1 888 359 3508
.