Author |
Message
|
kishoreraju |
Posted: Wed Jul 13, 2005 7:08 am Post subject: String Concatenation in ESQL |
|
|
Disciple
Joined: 30 Sep 2004 Posts: 156
|
When iam trying to execute below code
Declare cAppendStr char;
set cAppendStr=cAppendStr||'kishore Raju'
after exceuting the above statement i am getting NULL in cAppendStr.
is it default functionality of the esql. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jul 13, 2005 7:16 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
kirani |
Posted: Thu Jul 14, 2005 3:20 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Make use of COALESCE function. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
EddieA |
Posted: Thu Jul 14, 2005 8:16 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
Make use of COALESCE function. |
Not quite as easy, as I just found out.
COALESCE works great if the field/tag does not exist. But, if the field/tag is there, and has an empty value, then COALESCE leaves that empty value. Had to do a combination of IFNULL and COALESCE to catch everything.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
kirani |
Posted: Thu Jul 14, 2005 9:50 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
That's true! You will need more functions to catch everything. In this particular example, the ESQL can be like this,
Code: |
Declare cAppendStr char;
set cAppendStr=COALESCE(cAppendStr,'') || 'kishore Raju' ;
|
This will work fine if the cAppendStr is NULL. If it has empty value then ur approach is perfect! _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jul 15, 2005 3:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
EddieA wrote: |
But, if the field/tag is there, and has an empty value, then COALESCE leaves that empty value. |
Do you mean that the field has a value of '', or that the field has a value of NULL?
They aren't the same thing.
But a value of 'NULL' is not the same thing as a value of NULL either - although they are very hard to tell apart in a trace... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
EddieA |
Posted: Fri Jul 15, 2005 11:57 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Yeah. NULL, 'NULL', and '' have bitten me in the past. Especially when you switch between the Input tree and the Environment tree.
No, in this case, I was doing this:
Code: |
SET OutPutValue = COALESCE(InputBody.XMLDoc.InputField, ' '); (That a blank there) |
I got different results for:
1. <InputField/>
2. No InputField tag in XMLDoc
In the first case, it gave me back ''. In the second, the ' ' that I wanted.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
|