| Author | 
		  Message
		 | 
		
		  | MSAT | 
		  
		    
			  
				 Posted: Sat May 20, 2006 8:28 am    Post subject: How to implement Try catch in Compute node | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 17 Aug 2005 Posts: 62 Location: Bengalooru 
  | 
		  
		    
			  
				Hi All,
 
       I am trying to implement below algorithm in WBIMB 5.0 Compute node. But not able to succeed in this regard, can any one help me out?
 
 
> Select unique id from a table.
 
> Try to insert the id into another table (This table is having unique column).
 
> If failed to insert then add 1 to the previous value
 
> Again try to insert this new value in second table
 
> Loop this untill you left with a new value which inserts into the table
 
> replace this new value into the first table
 
 
Thanks
 
MSAT | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sat May 20, 2006 12:06 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Your algorithm sounds to me like a poor workaround for a situation gone bad.
 
 
You need to build a unique ID and pass it to both A and B tables so that the insert would work most of the time.
 
 
Now let's look at optimizing this. In the compute node you could try:
 
- read first if the id is already in table B -- then get max for column and add 1 -- insert in B substitue in A
 
 - if the  id is not in table B insert into B and done
 
  This really removes the multiple SQL calls in the loop.
 
 
As an alternative you can get the list of values from B and loop through the array looking for a gap in sequence and insert that gap.(I would not recommend it if your flow runs multiple instances.)
 
 
Enjoy    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | MSAT | 
		  
		    
			  
				 Posted: Sat May 20, 2006 10:44 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 17 Aug 2005 Posts: 62 Location: Bengalooru 
  | 
		  
		    
			  
				Yes u r right,
 
I am running multiple instances of the same flow.
 
I need to generated unique ID and send that to webservice, which really needs unique id for three different operations say A,B,C. We are facing problem with generation of these ID'. Because of the multiple instances the ID's getting duplicated and weservice throws duplicate transaction.
 
 
Let me know if you have any other solution for such scenario
 
 
Thanks
 
Satish | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jbanoop | 
		  
		    
			  
				 Posted: Sat May 20, 2006 11:25 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Chevalier
 
 Joined: 17 Sep 2005 Posts: 401 Location: SC 
  | 
		  
		    
			  
				You could look at generating the unique id on the database and using that.
 
 
You could look at somthing like sequence on the DB and use that as or part of the unique Id. 
 
Regards,
 
Anoop | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | MSAT | 
		  
		    
			  
				 Posted: Sun May 21, 2006 7:43 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 17 Aug 2005 Posts: 62 Location: Bengalooru 
  | 
		  
		    
			  
				Hi All,
 
Thanks for the reply.
 
As Anoop told I tried to use SEQUENCE in db2. I created sequence using below command
 
 
C:\>db2 create sequence test_seq start with 1 increment by 1 maxvalue 10 no cycle
 
DB20000I  The SQL command completed successfully.
 
 
and then used PASSTHRU function in ESQL which returned me the value.
 
But I need to use below piece of code like
 
SET Environment.TransID2[] = PASSTHRU('VALUES NEXTVAL FOR TRANS_COUNT2');
 
 
or else if i use as below I am getting an error like "Trying to assign or use a list as a scalar"
 
 
SET TransID1 = CAST((PASSTHRU('VALUES NEXTVAL FOR TRANS_COUNT1')) AS CHARACTER);
 
 
But I want the ouptput something like below.
 
<A>
 
<TransID>xxxx</TransID>
 
</A>
 
 
As of now the flow throwing exception when it tries to put the constructed message into the Q.
 
When I debug the flow the message looks something like
 
 
Environment
 
      TransId
 
           1
 
              xxxxxx
 
 
Any one know why is this happening?
 
 
Thanks
 
MSAT | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sun May 21, 2006 8:03 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Because you need to handle the fact that the DB call could potentially return multiple rows...       Even if in this case it will only be one row.     _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | MSAT | 
		  
		    
			  
				 Posted: Sun May 21, 2006 9:11 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 17 Aug 2005 Posts: 62 Location: Bengalooru 
  | 
		  
		    
			  
				Yes I agree but the requirement here is something like this.
 
Get 8 digit unique ID 
 
Assign that in the webmethids request field and call webservice.
 
So I was trying to implement half of this functionality (Only generate unique ID and assign to a field in the OutputRoot.)
 
By implwmenting below lines of code I am able togenerate three unique ID's from the DB2 SEQUENCE and I need to move ahead now.
 
 
 
DECLARE TransID1 CHARACTER;
 
DECLARE TransID2 CHARACTER;
 
DECLARE TransID3 CHARACTER;
 
		
 
SET Environment.TransID1[] = PASSTHRU('VALUES NEXTVAL FOR TRANS_COUNT1');
 
SET Environment.TransID2[] = PASSTHRU('VALUES NEXTVAL FOR TRANS_COUNT2');
 
SET Environment.TransID3[] = PASSTHRU('VALUES NEXTVAL FOR TRANS_COUNT3');
 
		
 
SET TransID1 = Environment.TransID1.*[1];
 
SET TransID2 = Environment.TransID2.*[1];
 
SET TransID3 = Environment.TransID3.*[1];
 
		
 
SET OutputRoot.XML.Info.TransID1 = TransID1;
 
SET OutputRoot.XML.Info.TransID2 = TransID2;
 
SET OutputRoot.XML.Info.TransID3 = TransID3;
 
 
Any way thanks for all
 
MSAT | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Sun May 21, 2006 9:48 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				Try using UUIDASCHAR or UUIDASBLOB, and skip the database stuff.
 
 
Look at a few results, and strip off the 8 bytes that change the most often. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |