Create function with a parameter, which will become the part of IN (1, 2, 3) clause
Use = ANY instead of IN

AND some_table.some_integer_field = ANY (some_other_parameter);


The equivalent of NOT IN would be &lt;&gt; ALL (...)

To declare a parameter with a default value use:

CREATE FUNCTION my_cool_func(..., p_id_list INTEGER[] default array[42])