iCode iCode - 8 months ago 91
SQL Question

Postgresql Request wtith array_to_string

Hello i am writting a pgsql function and inside this function , i have one request with array_to_string method.

AND id NOT IN (array_to_string(excludeArcs,','))

ID is an integer but array_to_string return string so :
Error result :
operator does not exist integer <> text

Someone can help me ?


Your query is equivalent to id NOT IN( '1,2,3' ). You can not compare ID with string.

It is necessary to expand the array to the table:

AND id NOT IN(select * from unnest(excludeArcs))