iCode iCode - 1 year ago 148
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 ?

Answer Source

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))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download