On Wed, 2016-06-08 at 23:50 -0400, David G. Johnston wrote:
>
> POn Wednesday, June 8, 2016, Patrick B <patrickbakerbr@gmail.com>
> wrote:
> > > ERROR: syntax error at or near "||"
> > > LINE 12: TO '/var/lib/pgsql/' || crtrow.account_id |...
> >
>
> Which tells me you cannot use an expression as a file name. The docs
> support this conclusion.
>
> You probably need to use EXECUTE after constricting a string.
>
> You could also try psql in a shell script.
>
> David J.
If this is something that you'll never ever have to do again in the
future, you could download ExecuteQuery which has a function to export
a result set as either XML or CSV delimited file output.
OTOH, if this is going to be something run on a regular basis, I think
you'd be better off writing a little program, or as David suggested
embedding this into a shell script.
HTH,
Rob