Trailing spaces - is there an easier way? - Mailing list pgsql-sql

From Dean Gibson (DB Administrator)
Subject Trailing spaces - is there an easier way?
Date
Msg-id 4CD30394.1030106@ultimeth.com
Whole thread Raw
Responses Re: Trailing spaces - is there an easier way?  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-sql
I'm sure this has been asked before, but I couldn't find it:<br /><br /> I have a "zzz CHAR (8)" field.  It needs to
beCHAR because trailing spaces need to be ignored for most operations.  However, I need to concatenate it with another
(literal)string and need the spaces to be significant in that operation.  The <b>ONLY WAY</b> I could find to do it  in
v9.0.1was (represented in the following function):<br /><br /><font color="#000099"><tt>CREATE OR REPLACE FUNCTION
padded(field CHAR ) RETURNS TEXT<br />     RETURNS NULL ON NULL INPUT<br />     IMMUTABLE<br />     LANGUAGE SQL AS
$SQL$<br/>         SELECT RPAD( $1, OCTET_LENGTH( $1 ) )<br />     $SQL$;</tt></font><br /><br /> And then of course I
write:<br/><br /><font color="#000099"><tt>SELECT padded( zzz ) || '/' || ...<br /></tt></font><br /> Is there a better
way?<br/><br /> 

pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: I'm stuck - I just can't get this small FUNCT to run!
Next
From: Pavel Stehule
Date:
Subject: Re: Trailing spaces - is there an easier way?