| Author | Message | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 4:28 am    Post subject: ARRAY |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 | 
			  
				| ARRAY 
 Last edited by 547c547 on Wed Nov 19, 2014 9:39 pm; edited 1 time in total
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | smdavies99 | 
			  
				|  Posted: Wed Nov 19, 2014 4:36 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 10 Feb 2003Posts: 6076
 Location: Somewhere over the Rainbow this side of Never-never land.
 
 | 
			  
				| When you run it what happens? does it work?
 does it fail?
 does the sun rise in the East every day?
 _________________
 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 |  | 
		
		  |  | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 5:06 am    Post subject: |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 | 
			  
				| It is not separting It is deleting all the records
 
 if I set the value in different tree , it is giving 10 records (my input is of 7 records )
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | McueMart | 
			  
				|  Posted: Wed Nov 19, 2014 5:08 am    Post subject: |   |  | 
		
		  |  Chevalier
 
 
 Joined: 29 Nov 2011Posts: 490
 Location: UK...somewhere
 
 | 
			  
				| This is is exactly the kind of thing I use the debugger for. You can step through line by line and work out exactly if it's behaving as expected, and if not, why not. 
 This really is programmer 101.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 5:13 am    Post subject: |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 | 
			  
				| Sorry to say this.. I debugged and tried in ample ways to separate but couldn't figure out how to separate. .
 
 One more method I tried, .. (NOT GIVING EXPECTED RESULT )
 
 
   
	| Code: |  
	| WHILE j < CARDINALITY(OLE.MRM.Record[])  DO SET i = 1;
 SET EV = OLE.MRM.Record[j];
 MOVE EV TO EV.Row;
 FOR  A AS OLE.MRM.Record[] DO
 IF POSITION(CAST(EV AS CHAR) IN  OLE.MRM.Record[i].Row)<> 0 AND i < CARDINALITY(OLE.MRM.Record[]) THEN
 DELETE FIELD  OLE.MRM.Record[i].Row;
 ELSE
 SET OLE.TEMP.Record[k].Row = OLE.MRM.Record[i].Row;
 SET k = k+1;
 END IF;
 SET i = i+1;
 END FOR;
 
 SET j = j+1;
 
 END WHILE;
 |  
 I would really appreciate your help
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Wed Nov 19, 2014 5:38 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| How is OLE.MRM.Record populated? _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | maurito | 
			  
				|  Posted: Wed Nov 19, 2014 6:02 am    Post subject: Re: Identify duplicates in file |   |  | 
		
		  | Partisan
 
 
 Joined: 17 Apr 2014Posts: 358
 
 
 | 
			  
				| 
   
	| 547c547 wrote: |  
	| DELETE FIELD OLE.MRM.Record[j] ; 
 ASAP .. PLEASE
 |  if you are going to delete records, DO NOT iterate from 1 to cardinality, as every time you delete the cardinality changes and the structure gets compressed, i.e. whatever you had in MRM.Record[100] will move to be MRM.Record[99] and so on, which will give you lots of trouble. So your loops should go from v to 1 rather than from 1 to v.
 Then, as it has been suggested, you need to work out the rest, use debugger, traces, etc.
 Start with a simple case, maybe 3 or 4 records.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | McueMart | 
			  
				|  Posted: Wed Nov 19, 2014 7:17 am    Post subject: |   |  | 
		
		  |  Chevalier
 
 
 Joined: 29 Nov 2011Posts: 490
 Location: UK...somewhere
 
 | 
			  
				| Additionally (I feel like a programming interviewer now) , the approach you are using is quite inefficient whereby you are testing every record against every other record. 
 A more efficient way of detecting duplicates in data is to do something like:
 
 - Create empty hash/map , MAP
 - For each data item A in data set S :
 - Does MAP contain A already?
 - If yes, remove item A from set S
 - If no, put A into MAP
 
 So as some more 'ESQL-like' pseudo code:
 
 
 
   
	| Code: |  
	| DECLARE hashRow ROW;
 DECLARE outputRow ROW;
 FOR record AS InputRow.Record[] DO
 IF NOT EXISTS(hashRow.{records.Row}) THEN
 CREATE LASTCHILD OF outputRow AS tmp NAME 'Record';
 SET tmp = record;
 CREATE LASTCHILD OF hashRow NAME record.Row;
 END IF;
 END FOR;
 
 |  
 Something like that...
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Wed Nov 19, 2014 11:49 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| And don't iterate with indexes, use references!      _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 11:17 pm    Post subject: .. |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 | 
			  
				| .. 
 Last edited by 547c547 on Wed Nov 19, 2014 11:22 pm; edited 1 time in total
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 11:19 pm    Post subject: .. |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | 547c547 | 
			  
				|  Posted: Wed Nov 19, 2014 11:21 pm    Post subject: |   |  | 
		
		  |  Acolyte
 
 
 Joined: 16 Jun 2014Posts: 51
 
 
 | 
			  
				| 
   
	| McueMart wrote: |  
	| Additionally (I feel like a programming interviewer now) , the approach you are using is quite inefficient whereby you are testing every record against every other record. 
 A more efficient way of detecting duplicates in data is to do something like:
 
 - Create empty hash/map , MAP
 - For each data item A in data set S :
 - Does MAP contain A already?
 - If yes, remove item A from set S
 - If no, put A into MAP
 
 So as some more 'ESQL-like' pseudo code:
 
 
 
   
	| Code: |  
	| DECLARE hashRow ROW;
 DECLARE outputRow ROW;
 FOR record AS InputRow.Record[] DO
 IF NOT EXISTS(hashRow.{records.Row}) THEN
 CREATE LASTCHILD OF outputRow AS tmp NAME 'Record';
 SET tmp = record;
 CREATE LASTCHILD OF hashRow NAME record.Row;
 END IF;
 END FOR;
 
 |  
 Something like that...
 |  
 
 
 Thankyou so much.. You took a lot pain and answered for my problem
 but Its not working .. .
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Thu Nov 20, 2014 5:48 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| @547c547 - there's no need and no point editing your posts to remove the content unless you've accidently included your SSN. 
 It makes responses nonsensical and removes any value this thread has to future readers.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |