in reply to DBI prepare and function recursion

The problem is in your recursion. What happens is:
  1. You enter the function rebuild_tree.
  2. You create a statement handler, using prepare.
  3. You call execute on it.
  4. You fetch once.
  5. You go into recursion.
  6. You call execute on it.
  7. You fetch once.
  8. You go into recursion, etc.
  9. If there's nothing more to fetch, you return from recursion.
  10. And then you fetch again, due to the while.
And it's this fetch that causes the problem. The corresponding execute has been cancelled because of the execute you did in recursion.

Abigail