last reference to cursor outside sql functions removed