If the error comes with an IN query, don't execute the query if the list or array is empty. just check the array is empty and ignore executing.