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 » Update WHERE question.

Post new topic  Reply to topic
 Update WHERE question. « View previous topic :: View next topic » 
Author Message
billybong
PostPosted: Mon Oct 10, 2005 5:59 am    Post subject: Update WHERE question. Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

Hi all!

This question might be basic, or might not. I've searched quite some time and havent got an answer so please dont flame me if its too easy.

If I have groups of fields (called Bookings), each with a REF_NO and SEQUENCE_NO, is it possible to do an inner join on both fields against a database table? In my table I dont have one primary key but two and it makes the query that much more cumbersome.

My environment fields might look something like this:

<Environment>
<Variables>
<Temp>
<Booking>
<REF_NO>
17869
</REF_NO>
<SEQUENCE_NO>
1
</SEQUENCE_NO>
</Booking>
<Booking>
<REF_NO>
17869
</REF_NO>
<SEQUENCE_NO>
2
</SEQUENCE_NO>
</Booking>
</Temp>
</Variables>
</Environment>

What I want to do is a query like this:

UPDATE Database.X as X
SET REPORT_ID = 'SomeID'
WHERE X.REF_NO = Environment.Variables.Temp.Bookings.REF_NO
AND X.SEQUENCE_NO = Environment.Variables.Temp.Bookings.SEQUENCE_NO;


But the above query only updates the first table row, not the second.
So, I tried using:

UPDATE Database.X as X
SET REPORT_ID = 'SomeID'
WHERE X.REF_NO = Environment.Variables.Temp.Bookings[].REF_NO
AND X.SEQUENCE_NO = Environment.Variables.Temp.Bookings[].SEQUENCE_NO;

But this code wont even deploy.
Any advice?
Back to top
View user's profile Send private message Visit poster's website
hopsala
PostPosted: Mon Oct 10, 2005 8:32 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Hm, what you want is for WBI to dynamically create a number of UPDATE statements in *runtime* according to your array length - and while I find this a nifty concept, I highly doubt this is at all possible, considering the way WBI compiles flows; so other than looping it, I can think of no other solution. (besides, since when does a programmer devoid himself the pleasures of loop-coding?)

I may be way off, though
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Oct 10, 2005 8:49 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

If I understand your question correctly you should be able to place the UPDATE in a WHILE statement, and loop over all your Booking elements in the environment (hint use CARDINALITY to see how many times you should loop) and then use array indexs to refer to each Booking as you go around the loop e.g. : (psudo code not tested)

SET NumberOfBookingElements = CARDALITY (Environment.Variables.Temp.Booking[]);
WHILE ( I < NumberOfBookingElements ) DO

UPDATE Database.X as X
SET REPORT_ID = 'SomeID'
WHERE X.REF_NO = Environment.Variables.Temp.Bookings[i].REF_NO
AND X.SEQUENCE_NO = Environment.Variables.Temp.Bookings[i].SEQUENCE_NO;

SET I = I +1;
END WHILE;


This will make one update call for each Booking you have

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
elvis_gn
PostPosted: Mon Oct 10, 2005 10:06 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi billybong,
I dont think there is a way out of looping.....

As mgk's post, the code should work like a charm, just to add to it, you could use a REFERENCE....

i.e (Not tested)

DECLARE Book_Ref REFERENCE TO Environment.Variables.Temp.Booking[1];

WHILE LASTMOVE(Book_Ref) DO

UPDATE Database.X as X
SET REPORT_ID = 'SomeID'
WHERE X.REF_NO = Book_Ref.REF_NO
AND X.SEQUENCE_NO = Book_Ref.SEQUENCE_NO;

MOVE Book_Ref NEXTSIBLING;

END WHILE;

Hope it helps.

Regards.
Back to top
View user's profile Send private message Send e-mail
billybong
PostPosted: Mon Oct 10, 2005 11:23 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

Thanks for the replies guys. It seems that there's no way around using multiple updates in a loop even though I really would like to solve it in a smoother way. I'll go with Elvis suggestion about using REFERENCE since I've read that its more efficient.
Back to top
View user's profile Send private message Visit poster's website
mgk
PostPosted: Tue Oct 11, 2005 12:25 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Indeed, a reference is the best way to go.
_________________
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
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Update WHERE question.
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.