Author |
Message
|
SOLOHERO |
Posted: Tue Jan 01, 2008 8:51 pm Post subject: Padding in ESQL |
|
|
Centurion
Joined: 01 Feb 2007 Posts: 107
|
Hi,
i want to pad a field with 0s in esql could you please tell me how can i do that.
My request messages comes with a 13 char field (corrId) , i am setting this value to MQMD.correId but as the CorreId takes only 48 bytes i have to pad the rest bytes with 0, could you please help me how can i do this.
Thanks.. _________________ Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jan 01, 2008 11:00 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you tried setting a shared low value 0x000000 to ablob?
Then assuming that the correl is not null
SET myblob = myblob || cblob;
And take the leftmost 24 bytes?
But seriously this looks like a design flaw. The correlid should be an anonymous identifier. Check the flags on the MQMD and move the corresponding msgid or correlid of the incoming msg to the response...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jan 02, 2008 5:16 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There is an OVERLAY function.
CorrelID does not need to be padded, though. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
SOLOHERO |
Posted: Thu Jan 03, 2008 8:54 pm Post subject: |
|
|
Centurion
Joined: 01 Feb 2007 Posts: 107
|
Thanks for your solutions, i got this thing fixed by concatinnating.
CREATE FUNCTION Paddings(IN CorrId CHARACTER ,IN SeqId CHARACTER) RETURNS BLOB
BEGIN
DECLARE Len_CorrId INTEGER;
DECLARE Len_SeqId INTEGER;
DECLARE Padd_CorrId CHARACTER;
DECLARE Padding CHAR '000000000000000000000000000000000000000000000000';
DECLARE PaddLen INT 48;
DECLARE PaddValue INTEGER ;
SET Len_CorrId= LENGTH(CorrId);
SET Len_SeqId=LENGTH(SequenceId);
--Calculate the PaddValue
SET PaddValue= (PaddLen)-(Len_CorrId + Len_SeqId);
SET Padd_CorrId =(SeqId || CorrId || (SUBSTRING(Padding FROM Len_CorrId+1 FOR PaddValue)));
RETURN CAST(Padd_CorrId AS BLOB);
END; _________________ Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jan 03, 2008 10:22 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
This is not really what you're looking for.
Char 00 and hex value 00 are not equivalent even with a CAST.
You should truly use the anonymous identifier pattern for the correlId.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fschofer |
Posted: Fri Jan 04, 2008 12:31 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Hi,
Quote: |
Char 00 and hex value 00 are not equivalent even with a CAST. |
If one cast a CHAR to BLOB without setting of CCSID and ECODING like SOLOHERO does the CHAR value will be directly converted 1:1 to a BLOB.
CAST('00' AS BLOB) result in x'00'
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/ak05680_.htm
Quote: |
If you specify neither the CCSID nor ENCODING clause, the string must itself contain two-character hexadecimal digits of the form X'hhhhhh' or hhhhhh (where h can be any hexadecimal characters). In this case, the input string "436174" becomes the same three-byte binary array (43,61,74).
Note that an error is generated if the input string is not of the correct format. |
Greetings
Frank |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jan 04, 2008 6:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Thanks for the update here , I'm learning every day with you guys.
Personally and to avoid confusion I would have used the form X'hhhhh'  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|