Issue 5967 get sql results macro improvements