Improvement of Execute Defined SQL function