in reply to Cant' commit transaction???
You have only one statement handle named $sth, it is the statement for your SELECT statement, not for your INSERT statement. You are trying to commit the SELECT which makes no sense. And you are trying to commit it during the fetch so it is still active. You need to prepare a second statement handle for the INSERT and commit that.