Hello everybody!

I've got a problem concatenating two fields (char(10) not null) in a select statement. Let's say the first field pname has the value
'USER ' and the second field pfirst the value 'JOE '. Then a "select pname||pfirst from table" would return the value 'USERJOE', trimming all spaces in the fields. This behaviour seems to be new in Release 7.4.5. Release 7.3.2 returns 'USER JOE', which makes more sense to me.
Is there any way to get my spaces back?
I'm working on SuSE-Linux 8.2

Best wishes

Thomas Niemeier

Search Discussions

  • Tom Lane at Sep 14, 2004 at 5:32 am

    "Thomas Niemeier" <thomas.niemeier@case-bielefeld.de> writes:
    I've got a problem concatenating two fields (char(10) not null) in a select statement. Let's say the first field pname has the value
    'USER ' and the second field pfirst the value 'JOE '. Then a "select pname||pfirst from table" would return the value 'USERJOE', trimming all spaces in the fields. This behaviour seems to be new in Release 7.4.5. Release 7.3.2 returns 'USER JOE', which makes more sense to me.
    The general feeling around here is that if you consider trailing spaces
    to be significant, you ought to be storing your data as varchar not
    char. The SQL spec is perfectly clear that trailing spaces in char(n)
    are not significant for comparison purposes. It's a bit vague about how
    to handle them otherwise, but we've found that supposing them to be
    significant for some operations but not others leads to all sorts of
    inconsistencies.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-bugs @
categoriespostgresql
postedSep 13, '04 at 11:17a
activeSep 14, '04 at 5:32a
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Thomas Niemeier: 1 post Tom Lane: 1 post

People

Translate

site design / logo © 2021 Grokbase