Depending on (the version of) your database driver, it might be that your database driver does not like more than one statement handle being active at the same time. In your case, that would be $searchSQL during the loop and in that loop the $insertSQL.
A workaround could be to first fetch all items into an array and then execute the insert for each element of that array.
In my experience, at least SQLite had this behaviour of not really wanting more than one active statement handle.
In reply to Re: fetchrow_array loop in perl 5.10
by Corion
in thread fetchrow_array loop in perl 5.10
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |