Bring sql function declare inside the function body