using transactional sql with nested loops and asynchronous callbacks; Scope an automatically invoked anonymous funciton to rescope i on the inner nest