0

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

1 Answer 1

1

Put the concatenation into the argument to format:

SELECT format(
      $$copy mytable(mycolums) from %L$$,
      :v1 || 'my/file/path.csv'
   ) \gexec
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.