Solve dynamic qry_add function