To quote one of the WROX books I have been reading on EVAL (I don't know which)
Avoid using EVAL inside of a loop, rather EVAL the loop, as EVAL will REINTERPERET
with EVERY ITERATION...so..using an EVAL inside of a loop causes a huge performance
loss...and it is doubly so in a nested loop.
Might I suggest using the DBI methods of retrieving ERROR codes REALLY is faster...AND:
(Since this is postgres..PREPING and EXECUTING is useless...PG doesn't understand
PREPARE the driver just allows it since it is a DBI call...DO is more practical here:
$query=" Select Statement;INSERT/UPDATE Statement;
$sth=$dbh->do(qq($query));
$err=$sth->err;
$result=$sth->result;
$rows=$sth->rows;
$errstr=$sth->errstr;
if ($result && ! $err) then { $sth->commit; } else {$sth->rollback;}
OR some such rot would be quicker and easier to debug SQL issues with. (Please Double
Check any syntax since it's a COMBO of Pseudo Code and REAL code...(I usually have to
have the DBI book out for syntax..and don't have it available at this time..)
> ***************
> prepare first select statement;
> prepare first update;
> prepare first insert;
> foreach
> eval {
> execute first select statement;
> execute first update or insert;
> commit;
> };
> if ($@) {
> rollback;
> next;
> }
>
> prepare second select statement;
> prepare second update;
> prepare second insert;
>
> foreach
> eval {
> execute second select;
> execute second update or insert;
> commit;
> };
> if ($@) {
> rollback;
> }
> }
> }
> ***************
>