On Fri, 15 Feb 2008, Ubence Quevedo wrote:
What would the command be to have a query result be put into a location/space
sensitive file [position 1 through 5 would be one thing where position 6
through 10 would be the next field, 11 through 16 another, etc]? Is this
even possible with Postgres?
Check out string operators like rpad and maybe even overlay in
http://www.postgresql.org/docs/current/static/functions-string.html , the
date/number formatting operations in
http://www.postgresql.org/docs/current/static/functions-formatting.html ,
and note that you can combine strings with || in between them.
You can do something like this:
select rpad(field1,5) || rpad(field2,5) || rpad(field3,5) from table1
To get back a string formatted the way you describe. You may have to
tweak that to get the formatting on the fields exactly right. Will be
kind of brute force and fragile if anything changes, but it should work if
you tinker enough.
--
* Greg Smith gsmith@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend