|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Concatenating spaces |
« View previous topic :: View next topic » |
Author |
Message
|
Ching |
Posted: Tue Mar 08, 2005 7:37 pm Post subject: Concatenating spaces |
|
|
 Apprentice
Joined: 08 Nov 2004 Posts: 25 Location: Portland, OR
|
I want to concatenate spaces to characters.
For example:
Let variableA = A, variableB = , variableC = C.
I want an out put:
A C
-----------------------------------------------
In my esql I have something like:
SET concatField = COALESCE(variableA, SPACE(1))||COALESCE(variableB,SPACE(1))||COALESCE(variableC,SPACE(1));
-----------------------------------------------
since B is empty, with coalesce it should concatenate a space right?
What I'm actually getting is:
AB
-------------------------------------
What happened to the space?
Thanks for any suggestions.
Ching |
|
Back to top |
|
 |
Ching |
Posted: Tue Mar 08, 2005 8:11 pm Post subject: |
|
|
 Apprentice
Joined: 08 Nov 2004 Posts: 25 Location: Portland, OR
|
since variableB exists, coalesce will concat empty with A and B.
So that's why output is AB.
I think I've answered my own question.
Ching |
|
Back to top |
|
 |
protocol |
Posted: Tue Mar 08, 2005 10:57 pm Post subject: |
|
|
 Apprentice
Joined: 25 Feb 2005 Posts: 41
|
Hi Ching,
The result is as expected.
If you want 'A B' then assign variable B = ' ' or better still use :
SET concatField =
COALESCE(variableA, SPACE(1))||' '||COALESCE(variableC,SPACE(1));
Protocol |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 09, 2005 4:40 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
variableB is empty.
Empty is not the same as NULL.
Coalesce only uses the default value when the field is NULL. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|