I don't know if this question better suits here or in SO ...
This is a script that I'd like to launch (the code of the function was copied from a question on SO):
\c mydb create or replace function truncate_tables(username in varchar) returns void as $$ declare stmt RECORD; statements cursor for select tablename from pg_tables where tableowner = username; begin for stmt in statements loop execute 'truncate table ' || quote_ident(stmt.tablename) || ' CASCADE ;'; end loop; end; $$ language 'plpgsql';
I get the following error:
ERROR: syntax at or near "$1" LINE1: $1 QUERY $1 CONTEXT: SQL statement in PL/PgSQL function "truncate_tables" near line 5
I am new to Postgres and PL/pgSQL and don't know what this error message means.