Tag Info

New answers tagged


You need to grant rights to use the function. GRANT EXECUTE ON Function to UserOrRole


You want RETURN QUERY EXECUTE for dynamic SQL. With RETURN QUERY you're trying to use a string literal as the start of a query. That's nonsensical and raises a syntax error. Also, use format with the %I and %L specifiers for identifiers and literals, instead of using concatenation. Otherwise you have SQL injection issues in your function.

Top 50 recent answers are included