mardi 24 février 2015

how to use variable value inside copy function



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');




Aucun commentaire:

Enregistrer un commentaire