From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@postgresql.org
Subject: Redirecting select() output generates error
Date: Mon, 29 Oct 2018 11:46:35 -0700 (PDT)
Message-ID: <alpine.LNX.2.20.1810291140010.17057@salmo.appl-ecosys.com> (raw)
This is puzzling and I've no idea what to do to fix it.
The table looks like this:
# select * from concentrations limit 2;
site_nbr | sampdate | medium | form | param | quant | unit | cen | floor | ceiling
----------+------------+---------+-------+-----------+-------+------+-----+-------+---------
10332 | 1979-11-06 | surface | total | inorganic | 0.5 | ug/L | 1 | 0 | 0.5
10332 | 1980-02-07 | surface | total | inorganic | 0.001 | ug/L | 1 | 0 | 0.001
Running this statement within psql works just fine (it's entered as a single
line but wrapped by alpine to fit the line limit):
select param, site_nbr, sampdate, min(quant), max(quant), unit from
concentrations group by param, site_nbr, sampdate, unit order by param,
site_nbr, sampdate, unit;
the output ends this way:
organic | 34198 | 2010-10-21 | 0.02 | 0.025 | ng/L
organic | 34198 | 2011-01-14 | 0.02 | 0.046 | ng/L
(585 rows)
But, when I try to redirect output to a disk file like this,
\o data-summary-by-form.txt
the result is an error:
# select param, site_nbr, sampdate, min(quant), max(quant), unit from concentrations group by param, site_nbr, sampdate, unit order by param, site_nbr, sampdate, unit;
ERROR: syntax error at or near "|"
LINE 1: | 1980-05-08 | 0.5 | 0.5 | ug/L
That line is not number 1 and I don't understand this behavior. Could it
be related to using hyphens in the filename rather than underscores?
Rich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rshepard@appl-ecosys.com
Subject: Re: Redirecting select() output generates error
In-Reply-To: <alpine.LNX.2.20.1810291140010.17057@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1810291140010.17057@salmo.appl-ecosys.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox