Trailing spaces - is there an easier way?
От | Dean Gibson (DB Administrator) |
---|---|
Тема | Trailing spaces - is there an easier way? |
Дата | |
Msg-id | 4CD30394.1030106@ultimeth.com обсуждение исходный текст |
Ответы |
Re: Trailing spaces - is there an easier way?
|
Список | 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 по дате отправления: