Reputation: 12555
This is very similar to the question here:
Postgresql - pass parameters to COPY in an sql script
But I'm stuck on how to use the format strategy that totally works when copying to a file, but I need to copy from a file, and pass in part of the file path:
--this doesnt work
SELECT format(
$$copy mytable(mycolums) from %L || 'my/file/path.csv'$$,
:v1
) \gexec
Upvotes: 0
Views: 513
Reputation: 247455
Put the concatenation into the argument to format
:
SELECT format(
$$copy mytable(mycolums) from %L$$,
:v1 || 'my/file/path.csv'
) \gexec
Upvotes: 1