ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL code needed urgent please

Post new topic  Reply to topic Goto page 1, 2  Next
 ESQL code needed urgent please « View previous topic :: View next topic » 
Author Message
mail2me.venky
PostPosted: Fri May 11, 2012 1:32 pm    Post subject: ESQL code needed urgent please Reply with quote

Apprentice

Joined: 11 May 2012
Posts: 26

Friends,

Currently i am using a MRM message set. also i want to set empty string
to all required mandatory fields.

i code like below.
--line 1 to line 11
Set OutputRoot.MRM.Body. Personal.age='';
Set OutputRoot.MRM.Body. Personal.sex='';
Set OutputRoot.MRM.Body. Personal.DOB='';
Set OutputRoot.MRM.Body. Personal.native='';
Set OutputRoot.MRM.Body. Personal.FirstName='';
Set OutputRoot.MRM.Body. Personal.TimeStamp.Day='';
Set OutputRoot.MRM.Body. Personal.TimeStamp.dash1='';
Set OutputRoot.MRM.Body. Personal.TimeStamp.month='';
Set OutputRoot.MRM.Body. Personal.TimeStamp.dash2='';
Set OutputRoot.MRM.Body. Personal.TimeStamp.yr='';
Set OutputRoot.MRM.Body. Personal.ratio='';

This code is very lengthy manner. Can someone help me please to optimize this code using CURSOR, NEXTSIBLING,MOVE esql functions.

I am struggling to do this in ESQL. please help me.urgent reply needed.
I tried like below for first 5 lines of above code, but not working properly

DECLARE cursor REFERENCE TO Set OutputRoot.MRM.Body. Personal;
MOVE cursor FIRSTCHILD;
WHILE LASTMOVE(cursor ) DO
SET cursor ='';
MOVE cursor NEXTSIBLING;
END WHILE;

The above not throwing error, also not creating Field in the output, but keep on iterating for 5 times, without setting empty string.

Please let me know what mistake i am doing.and give me the proper code for above code (--line 1 to line 11)complete scenrio.

Thanks in advance
varun


[/u]
Back to top
View user's profile Send private message Send e-mail
bruce2359
PostPosted: Fri May 11, 2012 3:10 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Pleading for immediate help on a WebSphere MQ post site, staffed by volunteers, about ESQL, on Friday? Really?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri May 11, 2012 3:41 pm    Post subject: Re: ESQL code needed urgent please Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Posting to the correct forum would also help.

mail2me.venky wrote:
Code:
DECLARE cursor REFERENCE TO Set OutputRoot.MRM.Body. Personal;
MOVE cursor FIRSTCHILD;
WHILE LASTMOVE(cursor )  DO
  SET cursor ='';
  MOVE cursor NEXTSIBLING;
END WHILE;

Aside from the syntax errors, this is the correct general approach. A usertrace would help explain what's actually happening.

Is OutputRoot empty? References do not create elements. They must be initialized or moved to elements that already exist, otherwise they get (silently) set to NULL; this does not itself cause an error, but LASTMOVE() would return FALSE.
Back to top
View user's profile Send private message
Vitor
PostPosted: Sat May 12, 2012 1:22 am    Post subject: Re: ESQL code needed urgent please Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mail2me.venky wrote:
Currently i am using a MRM message set. also i want to set empty string
to all required mandatory fields.

i code like below.


Why code at all? Why not enforce blank values for mandatory elements in the message set?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mail2me.venky
PostPosted: Sat May 12, 2012 2:59 am    Post subject: Re: ESQL code needed urgent please Reply with quote

Apprentice

Joined: 11 May 2012
Posts: 26

@rekarm01
Thanks rekarm01 for your kind reply .

i have added message definition project to my msg flow project references.

If i using code like below
--line 1 to line 11
Set OutputRoot.MRM.Body. Personal.age='';
Set OutputRoot.MRM.Body. Personal.sex='';
Set OutputRoot.MRM.Body. Personal.DOB='';
Set OutputRoot.MRM.Body. Personal.native='';
Set OutputRoot.MRM.Body. Personal.FirstName='';

It is creating elements and fields by setting empty string.
i.e elements and fields are already there in Output root message structure. i am just set the required value '' in the required field.

Can u explain me Why it is not possible in cursor/references. So that reduce the lines of code.

Also if possible , please share right code snippet.

@Vitor

Thanks Vitorfor your kind reply too.

I will do a work around and come back to you soon.

Mean while if possible , please share right code snippet .

Thanks to all.
Back to top
View user's profile Send private message Send e-mail
bruce2359
PostPosted: Sat May 12, 2012 5:07 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Moved to Message Broker forum
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun May 13, 2012 4:45 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

What rekarm01 was attempting to explain to you was that
Code:
DECLARE cursor REFERENCE TO Set OutputRoot.MRM.Body. Personal;

is only the incorrect code if the actual field OutputRoot.MRM.Body.Personal does not already exist when it is run.

If it does not exist, then your reference will be NULL, and LASTMOVE() will return FALSE and your loop will never run.

So we can't tell you the right code, because we don't know if your code is wrong in the first place, because we don't know if OutputRoot.MRM.Body.Personal already exists or not.

You should know if it already exists, and therefore should know if you need to create it or not. Once it's created, the rest of your code will work just fine.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun May 13, 2012 5:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

mqjeff wrote:
What rekarm01 was attempting to explain to you was that
Code:
DECLARE cursor REFERENCE TO Set OutputRoot.MRM.Body. Personal;

is only the incorrect code if the actual field OutputRoot.MRM.Body.Personal does not already exist when it is run.

If it does not exist, then your reference will be NULL, and LASTMOVE() will return FALSE and your loop will never run.

So we can't tell you the right code, because we don't know if your code is wrong in the first place, because we don't know if OutputRoot.MRM.Body.Personal already exists or not.

You should know if it already exists, and therefore should know if you need to create it or not. Once it's created, the rest of your code will work just fine.

On condition that all the child elements exist too...
Like Vitor said, it would be much easier to enforce this on the message set...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Sun May 13, 2012 6:48 am    Post subject: Re: ESQL code needed urgent please Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

I would do it like this:

Code:
SET OutputRoot.MRM.Body.Personal.age = '';
DECLARE refOutPersonal REFERENCE TO OutputRoot.MRM.Body.Personal;
SET refOutPersonal.sex = '';
SET refOutPersonal.DOB = '';
SET refOutPersonal.native = '';
SET refOutPersonal.FirstName = '';
SET refOutPersonal.TimeStamp.Day = '';
DECLARE refOutTimeStamp REFERENCE TO refOutPersonal.TimeStamp;
SET refOutTimeStamp.dash1 = '';
SET refOutTimeStamp.month = '';
SET refOutTimeStamp.dash2 = '';
SET refOutTimeStamp.yr = '';
SET refOutPersonal.ratio = '';


Afaics this is quite the minimal/minimum treewalking (on the OutputRoot) (possible)... without using "CREATE FIRSTCHILD/NEXTSIBLING" and "MOVE FIRSTCHILD/NEXTSIBLING".

You can move REFs only to where the "message structure" exists ("elements/fields exist").

Navigating on the OutputRoot is different than on the InputRoot, because you need to create elements !
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Sun May 13, 2012 11:08 pm    Post subject: Re: ESQL code needed urgent please Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Or the (slightly faster(!?), but less readable) version with CREATE and MOVE:

Code:
DECLARE rOutPersonal REFERENCE TO OutputRoot;
CREATE LASTCHILD OF rOutPersonal NAME 'MRM';MOVE rOutPersonal LASTCHILD;
CREATE LASTCHILD OF rOutPersonal NAME 'Body';MOVE rOutPersonal LASTCHILD;
CREATE LASTCHILD OF rOutPersonal NAME 'Personal';MOVE rOutPersonal LASTCHILD;
SET rOutPersonal.age = '';
SET rOutPersonal.sex = '';
SET rOutPersonal.DOB = '';
SET rOutPersonal.native = '';
SET rOutPersonal.FirstName = '';
DECLARE rOutTimeStamp REFERENCE TO rOutPersonal;
CREATE LASTCHILD OF rOutTimeStamp NAME 'TimeStamp';MOVE rOutTimeStamp LASTCHILD;
SET rOutTimeStamp.Day = '';
SET rOutTimeStamp.dash1 = '';
SET rOutTimeStamp.month = '';
SET rOutTimeStamp.dash2 = '';
SET rOutTimeStamp.yr = '';
SET rOutPersonal.ratio = '';


I think you can even replace the remaining "SET"s with "CREATE/MOVE LASTCHILD"s (and gain performance):

Code:
DECLARE rOutPersonal REFERENCE TO OutputRoot;
CREATE LASTCHILD OF rOutPersonal NAME 'MRM';MOVE rOutPersonal LASTCHILD;
CREATE LASTCHILD OF rOutPersonal NAME 'Body';MOVE rOutPersonal LASTCHILD;
CREATE LASTCHILD OF rOutPersonal NAME 'Personal';MOVE rOutPersonal LASTCHILD;
CREATE LASTCHILD OF rOutPersonal NAME 'age' VALUE '';
CREATE LASTCHILD OF rOutPersonal NAME 'sex' VALUE '';
CREATE LASTCHILD OF rOutPersonal NAME 'DOB' VALUE '';
CREATE LASTCHILD OF rOutPersonal NAME 'native' VALUE '';
CREATE LASTCHILD OF rOutPersonal NAME 'FirstName' VALUE '';
DECLARE rOutTimeStamp REFERENCE TO rOutPersonal;
CREATE LASTCHILD OF rOutTimeStamp NAME 'TimeStamp';MOVE rOutTimeStamp LASTCHILD;
CREATE LASTCHILD OF rOutTimeStamp NAME 'Day' VALUE '';
CREATE LASTCHILD OF rOutTimeStamp NAME 'dash1' VALUE '';
CREATE LASTCHILD OF rOutTimeStamp NAME 'month' VALUE '';
CREATE LASTCHILD OF rOutTimeStamp NAME 'dash2' VALUE '';
CREATE LASTCHILD OF rOutTimeStamp NAME 'yr' VALUE '';
CREATE LASTCHILD OF rOutPersonal NAME 'ratio' VALUE '';


I am not sure if it is even better to actually move the references into the "final" fields (leafs of the tree) (the ones that have a "VALUE" (in your case just the empty string (''))) and do CREATE NEXTSIBLING and then MOVE NEXTSIBLING (does anybody know ?!... or is "CREATE LASTCHILD" the fastest way to "add elements/fields" ... I think it is very fast to "append (CREATE LASTCHILDs) at the end"). Anyway, here is the version with NEXTSIBLING:

Code:
DECLARE rOut REFERENCE TO OutputRoot;
CREATE LASTCHILD OF rOut NAME 'MRM';MOVE rOut LASTCHILD;
CREATE LASTCHILD OF rOut NAME 'Body';MOVE rOut LASTCHILD;
CREATE LASTCHILD OF rOut NAME 'Personal';MOVE rOut LASTCHILD;
CREATE LASTCHILD OF rOut NAME 'age' VALUE '';MOVE rOut LASTCHILD;
CREATE NEXTSIBLING OF rOut NAME 'sex' VALUE '';MOVE rOut NEXTSIBLING;
CREATE NEXTSIBLING OF rOut NAME 'DOB' VALUE '';MOVE rOut NEXTSIBLING;
CREATE NEXTSIBLING OF rOut NAME 'native' VALUE '';MOVE rOut NEXTSIBLING;
CREATE NEXTSIBLING OF rOut NAME 'FirstName' VALUE '';MOVE rOut NEXTSIBLING;
CREATE NEXTSIBLING OF rOut NAME 'TimeStamp';MOVE rOut NEXTSIBLING;
DECLARE rOut2 REFERENCE TO rOut;
CREATE LASTCHILD OF rOut2 NAME 'Day' VALUE '';MOVE rOut2 LASTCHILD;
CREATE NEXTSIBLING OF rOut2 NAME 'dash1' VALUE '';MOVE rOut2 NEXTSIBLING;
CREATE NEXTSIBLING OF rOut2 NAME 'month' VALUE '';MOVE rOut2 NEXTSIBLING;
CREATE NEXTSIBLING OF rOut2 NAME 'dash2' VALUE '';MOVE rOut2 NEXTSIBLING;
CREATE NEXTSIBLING OF rOut2 NAME 'yr' VALUE '';
CREATE NEXTSIBLING OF rOut NAME 'ratio' VALUE '';


There are some nice explanations about "SET" (and "CREATE FIELD") and "CREATE(/MOVE) FIRSTCHILD/NEXTSIBLING"

Note that all this CREATE/MOVE FIRSTCHILD/LASTCHILD looks cumbersome/tedious but it (basically) is just the low-level API that "SET" also uses.

"SET OutputRoot...myField" will just likely use it more intensly / less efficient (than if you just write it yourself).
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon May 14, 2012 3:45 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Have you ever tried
Code:
CREATE LASTCHILD OF ref AS ref NAME 'xyz' VALUE 'klm';

Saves the move you show at the end of your command...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Mon May 14, 2012 3:58 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

fjb_saper wrote:
Have you ever tried
Code:
CREATE LASTCHILD OF ref AS ref NAME 'xyz' VALUE 'klm';

Saves the move you show at the end of your command...


Thank you for the shortcut, I actually/honestly haven't been aware of that.

So what is better: To use LASTCHILD (only) or to use (LASTCHILD & )NEXTSIBLING combined ?!
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
mail2me.venky
PostPosted: Mon May 14, 2012 9:39 pm    Post subject: Reply with quote

Apprentice

Joined: 11 May 2012
Posts: 26

Hi Friends

Thanks for all your efforts and reply.

Just a clarification, is it possible to create a output message structure using output message definition project. or say if the mxsd is given , is it possible to create a output message structure IN ESQL.

if it is possible, may be i can try to use REFERENCES/CURSOR techinique to set the values.

please share code snippet.

Thanks
varun
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Mon May 14, 2012 11:12 pm    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

There are things that the msg-set does (the (out-)parsing) and there are things that you do in code (e.g. ESQL)... e.g. align left/right or padding with e.g. "0" can be done in the msg-set.

In ESQL you need to create the proper (tree-)structure and fill in the (field-)values. In your msg set (mxsd) you define your msg structure and in your ESQL you create it (both must match, otherwise the parser complains).

As a first step you can just write your code so that it is filled with dummy values (as you/we actually did up to now) and then make sure the writing/parsing-out works as desired. MRM is/can be (much) more challenging than XMLNSC btw.

I recommend to you to make sure that the out-part works first. Then you put in the code for getting the valus from the input msg.
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue May 15, 2012 2:39 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
is it possible to create a output message structure using output message definition project. or say if the mxsd is given , is it possible to create a output message structure IN ESQL.
No. ESQL has no facilities for querying the structure or settings in the message set. This is not an accidental omission, btw - it is by design. One of the key design goals of WMB was to isolate all knowledge about the format of the data in message sets, so that message flows can deal with the logical structure and logical values of the data. It's a powerful concept.

Having said that, you are not the first person to want this facility, and in fact the DFDL domain in WMB v8 can apply default values to all required ( minOccurs>0 ) fields in a message.

If your message format is entirely fixed-length then you can do the same trick using the MRM parser - that's what Vitor was suggesting earlier in this thread. Just set the default value to the empty string in the Logical properties of each required element. If your output format is XML or variable-length then you cannot use this technique.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL code needed urgent please
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.