This the main error:
ERROR: operator does not exist: integer = character varying
You code is trying to match an integer and a string, that's not going to work. Fix your code, get the query that is involved to see if you fixed it. See also the PostgreSQL log files.
A workaround (NOT A SOLUTION!) is to do some casting. Check this article.