Fix sql syntax error if the orderIds list is null or empty.