[postgis-users] quickie question

Stephen Marshall smarshall at wsi.com
Tue May 2 09:06:59 PDT 2006


Meghan,

You are trying to use psql backslash commands within a plpgsql 
server-side function.  The backslash commands are specific just to the 
psql application, which is just one specific PostgreSQL client 
application.  The plpglsql code runs within the PostgreSQL backend (i.e. 
on the server-side), and hence is independent of which client program or 
interface you are using.

Typically, to output the results of a server-side function to a file, 
write your function to return a set of records, i.e. SETOF <table_name 
or aggregate data type>.   You can define the record type either with 
the create table or create type commands.

Then, execute your function using psql (or another client application) 
and redirect the output of the client application into a file.

e.g. This command will output your query results as comma-separated 
variables and redirect it into a file.

psql --no-align -F, --pset footer -c "your query" yourdb  >  yourfile

Yours,
Steve Marshall



More information about the postgis-users mailing list