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 » ABOUT ESQL "MOVE"

Post new topic  Reply to topic
 ABOUT ESQL "MOVE" « View previous topic :: View next topic » 
Author Message
caoyuxing
PostPosted: Tue Feb 15, 2011 10:06 pm    Post subject: ABOUT ESQL "MOVE" Reply with quote

Newbie

Joined: 15 Feb 2011
Posts: 4

HI,guys
I have used "MOVE" as documents guide.here is the sample code.


Code:
WHILE LASTMOVE(sourceCursor) DO
    SET targetCursor.ItemNumber  = sourceCursor.item;
    SET targetCursor.Description = sourceCursor.name;
    SET targetCursor.Price       = sourceCursor.prc;
    SET targetCursor.quantity    = 1;
    CREATE NEXTSIBLING OF targetCursor AS targetCursor REPEAT;
    MOVE sourceCursor NEXTSIBLING REPEAT TYPE NAME;
END WHILE;


But it will build a blank "targetCursor". Because it has already created "targetCursor" even "WHILE" is false.
Now I delete the blank targetCursor using "DELETE FILED".
Can you tell me a more smooth way to do it ,without "DELETE" will be better!thanks!
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Feb 16, 2011 12:40 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

It has always been difficult to find any mention of 'DO' statement in the documentation, but I recall having done this several times:

Code:
DO
     -- do something
WHILE LASTMOVE(cursor)
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Feb 16, 2011 12:54 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Sorry,

That is the way you do it in java. IN ESQL you do it with a LOOP which you LEAVE when the condition (LASTMOVE) is no longer true.
Back to top
View user's profile Send private message
fatherjack
PostPosted: Wed Feb 16, 2011 12:58 am    Post subject: Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

Rather than CREATE NEXTSIBLING you can CREATE LASTCHILD of taregtSource's parent before you SET the targetSource elements.
_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Feb 16, 2011 1:09 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

fatherjack wrote:
Rather than CREATE NEXTSIBLING you can CREATE LASTCHILD of taregtSource's parent before you SET the targetSource elements.


Yes, but he has obviously done it before entering the WHILE loop.

So, do it this way:

Code:

LOOP
  Set the fieds
  Move SourceCursor
  if LASTMOVE is false, LEAVE
  MOVE targetCursor NEXTSIBLING
END LOOP
Back to top
View user's profile Send private message
fatherjack
PostPosted: Wed Feb 16, 2011 1:20 am    Post subject: Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

Esa wrote:
Yes, but he has obviously done it before entering the WHILE loop.


So delete that line of code.

Esa wrote:
So, do it this way


There is more than one way to skin a cat.
_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Feb 16, 2011 1:31 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

fatherjack wrote:

So delete that line of code.


Think again.

fatherjack wrote:

There is more than one way to skin a cat.


True. Sorry that I cut it straight. I must have suddenly got bored of encouraging people to examine the manuals. In the future I will try to be more alert and follow the customs of this forum
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Feb 16, 2011 1:45 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

FYI, the ESQL equivalent of DO ... WHILE is the REPEAT ... UNTIL statement:

Code:
REPEAT [statements] UNTIL [condition] END REPEAT



Kind Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Feb 16, 2011 2:17 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Thanks, mgk

I thought there was a way. I should have examined the manuals more carefully myself

Anyhow, LOOP gives you more control and I think it fits this case better.
Back to top
View user's profile Send private message
caoyuxing
PostPosted: Wed Feb 16, 2011 11:13 pm    Post subject: Reply with quote

Newbie

Joined: 15 Feb 2011
Posts: 4

mgk wrote:
FYI, the ESQL equivalent of DO ... WHILE is the REPEAT ... UNTIL statement:

Code:
REPEAT [statements] UNTIL [condition] END REPEAT



Kind Regards,


I have tried this way,and we will face the same problem
Back to top
View user's profile Send private message
caoyuxing
PostPosted: Wed Feb 16, 2011 11:16 pm    Post subject: Reply with quote

Newbie

Joined: 15 Feb 2011
Posts: 4

Esa wrote:
Thanks, mgk

I thought there was a way. I should have examined the manuals more carefully myself

Anyhow, LOOP gives you more control and I think it fits this case better.


thanks for your reply!But I have not fully understood fatherjack...
Back to top
View user's profile Send private message
fatherjack
PostPosted: Thu Feb 17, 2011 1:15 am    Post subject: Re: ABOUT ESQL "MOVE" Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

I meant something like this

Code:
WHILE LASTMOVE(sourceCursor) DO
    CREATE LASTCHILD OF targetParent AS targetCursor NAME 'Fred';
    SET targetCursor.ItemNumber  = sourceCursor.item;
    SET targetCursor.Description = sourceCursor.name;
    SET targetCursor.Price       = sourceCursor.prc;
    SET targetCursor.quantity    = 1;
    MOVE sourceCursor NEXTSIBLING REPEAT TYPE NAME;
END WHILE;


I've not run this so syntax may not be perfect.
_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ABOUT ESQL "MOVE"
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.