Thanks to all for the helpful ideas.
Now I'm edjic^H^H^H^Hjdic^H^H^H^H^H learned.
On Thu, 13 Sep 2001, Philip Newton wrote:
> Yes; I do that frequently. That's really why there's a difference between
> preparing and executing; I usually prepare all the statements I will need at the
> beginning of my script (once) and can then execute them repeatedly, as often as
> I need. This also saves the database work (if it supports that sort of thing),
> since it only has to analyse and translate the statement once.
PostgreSQL apparently doesn't support this.
> frequently store them in a hash -- something like this:
>
> my(%sql, %handle);
>
> $sql{'insertbla'} = <<EOSQL;
> insert into bla (foo, bar)
> values (?, ?)
> EOSQL
> # then, prepare them all by looping through (keys %sql) and doing a
> # $dbh->prepare for each string and storing the resulting statement handle
> # in $handle{$key}
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.