i pass some array integer arguments to my function. inside, i'd like to check if the passed array isn't empty, and then build a clause to check if the selected values are included in this array.
"brand_types" below is an alias for an integer argument
it gives me a parse error on 'not null'
if (brand_types not null) then
wherestring := wherestring || ' AND brand_id IN ' || brand_types ;
what are the plpgsql synonyms for (for example) the php empty($array), and in_array($value, $array) ?
the field is an integer, but the argument is an array. must check if the field value is in this array.. is it possible without looping and adding "and brand_id=array[n]" (when the array is huge, the generated query would be enormous) :/ ?
maybe let's make the question easier:
what sould be instead of "=" in order to make this query work? "IN" doesn't work either
select * from ads_all where id>0 and brand_id = array[1,2,3,4,5];