pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Susan Hurst <susan.hurst@brookhurstdata.com>
To: pgsql-general@postgresql.org
Subject: Space Stalker in SQL Output
Date: Wed, 27 Jun 2018 14:09:23 -0500
Message-ID: <8ad8301badea6566622771129517cf02@mail.brookhurstdata.net> (raw)


Why would a psql statement insert a leading space into the output, which 
is a single integer value?

The leading space caused my job call to fail elsewhere in the same shell 
script as the psql call.  Here is the anonymized version of the psql 
call to assign a value to a shell script variable:

IDz=`psql -d proddb -U produser -h 10.9.999.99 -p 99900 -t < 
last_id.sql`

The output is simply a max(id) value, which is defined as an integer 
data type in the source table column.  The output looked like this 
(notice the leading space before the integer value):

echo “IDz =${IDz}
IDz =’ 100’

The last_id.sql itself is simply:  select max(id) from prodtable;

I'm using:

PostgreSQL 9.5.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 
20120313 (Red Hat 4.4.7-16), 64-bit

I fixed the output in the shell script with a tr command but why should 
that be necessary?  What is causing the space to be prepended to integer 
value?


ID=`echo ${IDz} | tr -d ''`
IDz =’100’

Knowing the root cause of the space stalker would be most helpful.  
Thanks for your help!

Sue


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Susan E Hurst
Principal Consultant
Brookhurst Data LLC
Email: susan.hurst@brookhurstdata.com
Mobile: 314-486-3261




view thread (4+ messages)  latest in thread

Message-ID: <8ad8301badea6566622771129517cf02@mail.brookhurstdata.net>
Permalink:  ../8ad8301badea6566622771129517cf02@mail.brookhurstdata.net/
Also on:    postgresql.org/message-id/8ad8301badea6566622771129517cf02@mail.brookhurstdata.net

 · 

reply

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: susan.hurst@brookhurstdata.com
  Subject: Re: Space Stalker in SQL Output
  In-Reply-To: <8ad8301badea6566622771129517cf02@mail.brookhurstdata.net>
  References: <8ad8301badea6566622771129517cf02@mail.brookhurstdata.net>

* 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