Page 1 of 1

sequential file clarification

Posted: Sun Jun 15, 2014 5:39 am
by vamsi.4a6
source is sequential file.
Requirement:
Input file's data should be distributed like 1st 3 row in file1, next 3 row in file2, next 3 rows in file3 again next 3 rows in file1 and continues.

Currently we have less records in source so i generated rownum in sequential filestage and put
constraint in transformer which is not good practise.Without hardcoding constraints in transformer is there any way to do it.

Posted: Sun Jun 15, 2014 8:15 am
by chulett
Me, I'd use Mod() to control the constraint.

Posted: Sun Jun 15, 2014 11:26 am
by vamsi.4a6
Not sure how to proceed using MOd fuction after thinking for long time

Posted: Sun Jun 15, 2014 1:37 pm
by qt_ky
Constraints are very useful. Why would someone suggest not to use constraints?

Posted: Sun Jun 15, 2014 1:42 pm
by chulett
Off the top of my head, Mod() the record number by 9 and then use three sets of three values for the constraints: 1,2,3 to first file; 4,5,6 to the second and 7,8,0 to the third.

Posted: Sun Jun 15, 2014 10:17 pm
by vamsi.4a6
It is perfectly working.Thanks

@Eric

I do not have any issue to use the constraint but what craig provided is generalized solution which will handle any volume of data

Posted: Mon Jun 16, 2014 1:37 am
by ssnegi
You can also have stage variable in transformer in sequential mode :
svcnt Initial Value 0 : if svcnt < 9 and then svcnt+1 else 1
Then put contraints :
FILE1 : svcnt =1 or svcnt = 2 or svcnt = 3
FILE2 : svcnt =4 or svcnt = 5 or svcnt = 6
FILE3 : svcnt =7 or svcnt = 8 or svcnt = 9

Posted: Mon Jun 16, 2014 2:26 am
by ray.wurlod
Slower (because of spurious requirement for sequential mode) and less efficient (because of additional CPU cycles for calculation) than the Mod() function already suggested.