I'm a beginner in Postgres and I want to automate dropping a column from a table with a function. But it gives me the error I mentioned in the title.
Here's my code:
create function dropColumn(table_name text,col_name text) returns void as $$
ALTER TABLE $1 DROP COLUMN IF EXIST $2;
$$
language 'psql';
Error:
ERROR: syntax error at or near "$$ language 'psql'; create function dropColumn(table_name text,col_name text) returns void $$" LINE 1: $$
What's the problem? How can I fix this?