in reply to perl and database: argument for the prepare method

In the semantics of the situation, “prepare” is supposed to correspond to the step when the SQL string is transformed into an execution-plan that can be carried out one-or-more times, using different placeholders (which are merely “inputs”), without the overhead of recalculating the execution plan.   A module on the server-side known as the “query optimizer” constructs the plan.

Replies are listed 'Best First'.
Re^2: perl and database: argument for the prepare method
by GotToBTru (Prior) on Jun 06, 2014 at 14:30 UTC

    Exactly. If you will be executing a statement multiple times, you only need prepare it once. This will save time.

    $update=<<UPDATE; update foo set bar = ? where id = ? UPDATE $dbstmt = $dbhandle->prepare($update); foreach $recid (keys %records) { $dbstmt->execute($newvalues{$recid}, $recid); }
    1 Peter 4:10