hi,

I am using psql through windows command prompt. I have a for loop in a file input.sql and I am trying to execute it.

input.sql:

for tbl in 'psql -U postgres -qAt -c "select tablename from my_tables where schemaname = 'myschema';" mydb' ;
do
psql -U postgres -c "alter table myschema.$tbl owner to usr1" mydb;
done;

command prompt :
> psql -U postgres -f input.sql

error displayed:

psql:./tmp/input.sql:2: ERROR: syntax error at or near "for"
LINE 1: for tbl in 'psql -U postgres -qAt -c "select tablename from ...
^
psql:./tmp/input.sql:4: ERROR: syntax error at or near "psql"
LINE 2: psql -U postgres -c "alter table myschema.$tb...
^
psql:./tmp/input.sql:5: ERROR: syntax error at or near "done"
LINE 1: done;
^

Am i missing anything. Is the for loop syntax correct ? please help.