I want to send data to .csv file using COPY
function in Postgres. But I am using anonymous block so my table name should be value of variable.
COPY (SELECT cname.portal from user) To '/tmp/out.csv' With CSV;
Where cname
is my variable inside anonymous block. I try to use EXECUTE
format but it also didn't work. I tried something like:
EXECUTE format (' COPY (select * from %s.portal,cname ) To '/tmp/out1.csv' With CSV');