How to do WHERE x IN (val1, val2,...) in plpgsql
IN (...) expects a literal list of values.

If you write x IN (some_array) then PostgreSQL expects x to also be an array, since you're testing to see whether the array x appears in the one-element list of arrays (some_array).

If you instead want to see if the value x appears as an element of the array some_array you must write:

x = ANY (some_array)


(Note that you can use ANY with pretty much any operator, not just =, and that there's an ALL as well as an ANY.)