I'm interested in getting the content of a SQL query into a file (possibly as an INSERT clause). Is it possible to be done with an SQL statement? Now I think it could be realised as [\copy (statement) to 'file'] construction, but it's psql command. Is there another way?