Author |
Message
|
HarishKDewangan |
Posted: Tue Feb 14, 2012 2:44 am Post subject: How to Store trace data in a variable using esql |
|
|
Novice
Joined: 23 Sep 2011 Posts: 13
|
I have a requirement of storing the trace data in a variable as String
Trace data :
(0x01000013):body = (
(0x0300000B):numberOfRecordsReturned = 0
(0x0300000B):totalRecordsFound = 0
).....
)
Trace node equivalent code : ${Root.MRM}
I have to store 'Data in bold' which is a logical tree into a string using esql something like this :
Declare INPUTSTR CHARACTER;
SET INPUTSTR = CAST(InputBody As Character);
If anyone has idea of how to do this, please let me know.
Thanks in advance!!!
Harish |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 14, 2012 2:58 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you need to convert a message tree into a flattened bitstream, you need to use ASBITSTREAM function in ESQL. |
|
Back to top |
|
 |
HarishKDewangan |
Posted: Tue Feb 14, 2012 3:53 am Post subject: |
|
|
Novice
Joined: 23 Sep 2011 Posts: 13
|
I did try the ASBITSTREAM like this :
DECLARE Inputmsg CHARACTER;
DECLARE bSourceText CHARACTER ASBITSTREAM(InputBody);
SET Inputmsg = CAST(bSourceText AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId);
But it says "Invalid wire format".
Actually I am passing a flat string to CWF wire format (Domain : MRM) & trying to store the logical tree as it is in string variable.
MQInput ---> ComputeNode----> MQOutput |
|
Back to top |
|
 |
adubya |
Posted: Tue Feb 14, 2012 3:57 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Code: |
DECLARE bSourceText CHARACTER |
Shouldn't this be a BLOB ? |
|
Back to top |
|
 |
HarishKDewangan |
Posted: Tue Feb 14, 2012 4:22 am Post subject: |
|
|
Novice
Joined: 23 Sep 2011 Posts: 13
|
After changing bSourceText to BLOB, Inputmsg variable has the same value what I passed as input (flatstring), but my requirement is to have the complete logical tree as string which I mentioned below. |
|
Back to top |
|
 |
mqsiuser |
Posted: Tue Feb 14, 2012 4:44 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Just to put up an alternative to the ASBITSTREAM function: Use FIELDNAME to get the name of the element and construct the string (CHAR) manually
Probably use FIELVALUE, though I am currently not sure why you should.
There is a post in this forum, where someone wrote this in Java (which probably is the counterpart to this).
As a task write the code in ESQL and let us know. _________________ Just use REFERENCEs
Last edited by mqsiuser on Tue Feb 14, 2012 4:55 am; edited 2 times in total |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 14, 2012 4:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You can also use string concatenation to build your flattened string, if you don't choose to pass enough information in to asbitstream to give it what it needs. |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Feb 14, 2012 7:58 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
There are plenty of posts in this foum asking the very same question.
Viz
How do I put a complete Tree into a single string vairable.
Mr Google is your firend here. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqsiuser |
Posted: Tue Feb 14, 2012 8:19 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
smdavies99 wrote: |
There are plenty of posts in this foum asking the very same question.
Viz
How do I put a complete Tree into a single string vairable.
Mr Google is your firend here. |
Pointing to google !? Sorry, that doesn't help too much. What is your favorite approach. ASBITSTREAM, coding yourself or what else ?! If you point to google then also supply a link ... please. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 14, 2012 8:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqsiuser wrote: |
If you point to google then also supply a link ... please. |
www.google.com
Seriously, pointing someone to Google is shorthand for "there are loads of potential methods, do some research, pick one that meets your requirements and post back here if you have a specific problem".
mqsiuser wrote: |
What is your favorite approach. ASBITSTREAM, coding yourself or what else ?! |
You don't have favourite methods. You have the one that works best for your particular requirement. Sometimes there's a "best practice" one that works for most requirments.
Sometimes there's one that never works best (like itterating through a message tree with CARDINALITY). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqsiuser |
Posted: Tue Feb 14, 2012 8:47 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Vitor wrote: |
Seriously, pointing someone to Google is shorthand for "there are loads of potential methods, do some research, pick one that meets your requirements and post back here if you have a specific problem". |
fair enough
Vitor wrote: |
Sometimes there's a "best practice" one that works for most requirments.
Sometimes there's one that never works best (like itterating through a message tree with CARDINALITY). |
There are misperceptions. Some hints, ups and downs are also nice to hear some times. Some current discussions, since time progresses! Google is an historical archive. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 14, 2012 9:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqsiuser wrote: |
Google is an historical archive. |
Don't let their lawyers hear you say that. Each Google search is a fresh Dance across the Internet.
The results of such a search will turn up all the solutions people have written and discussed on the web, which is what most people want. If you want a more targetted search, use the little box top right of this page which is Powered By Google. No threads are deleted in here either. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
HarishKDewangan |
Posted: Wed Feb 15, 2012 3:18 am Post subject: |
|
|
Novice
Joined: 23 Sep 2011 Posts: 13
|
Thanks all for your quick replies.
This is how I did it :
Code: |
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
set OutputRoot.Properties.MessageFormat = 'XML1';
DECLARE flatstructure character;
SET flatstructure = '';
call ComposeDetails(InputBody,flatstructure);
--flatstructure has all the fieldName:fieldValue pair...
END;
CREATE PROCEDURE ComposeDetails(IN root REFERENCE,INOUT flatstructure CHARACTER) BEGIN
Declare fieldName CHARACTER;
Declare fieldValue CHARACTER;
SET fieldName = FIELDNAME(root);
SET fieldValue = FIELDVALUE(root);
IF (fieldValue is not null) THEN
SET flatstructure = flatstructure||fieldName ||':' ||fieldValue;
ELSE
SET flatstructure = flatstructure||fieldName ;
end if;
DECLARE cursor REFERENCE TO root;
MOVE cursor FIRSTCHILD;
WHILE LASTMOVE(cursor)
DO CALL ComposeDetails(cursor,flatstructure);
MOVE cursor NEXTSIBLING;
END WHILE;
END;
|
Thanks once again to mqjeff & mqsiuser for your suggestion. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 15, 2012 5:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Warning: looking as you are a newbie on the forum, supplied the code tags for you. Next time don't forget to use them!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
HarishKDewangan |
Posted: Wed Feb 15, 2012 5:24 am Post subject: |
|
|
Novice
Joined: 23 Sep 2011 Posts: 13
|
Sure thing fjb_saper  |
|
Back to top |
|
 |
|