Load last 2 Entries
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 19
- Joined: Sat Dec 19, 2009 8:50 am
- Location: Chennai
Load last 2 Entries
Hi
My source and target are csv file. It contains the data as follows.
CNO CNAME RISKRATINGS ENTRY_TIMESTAMP
100 , ABC , 2 , 2011-02-03 10:15
100 , ABC , 3 , 2011-02-02 10:10
100 , ABC , 1 , 2011-02-04 12:15
101 , XYZ , 2 , 2011-02-03 10:12
101 , XYZ , 3 , 2011-02-04 16:13
For each CNO i want last 2 records based on the ENTRY_TIMESTAMP. The result should be as follows.
CNO CNAME RISKRATINGS ENTRY_TIMESTAMP
100 , ABC , 2 , 2011-02-03 10:15
100 , ABC , 1 , 2011-02-04 12:15
101 , XYZ , 2 , 2011-02-03 10:12
101 , XYZ , 3 , 2011-02-04 16:13
Your inputs are greatly appreciated.
My source and target are csv file. It contains the data as follows.
CNO CNAME RISKRATINGS ENTRY_TIMESTAMP
100 , ABC , 2 , 2011-02-03 10:15
100 , ABC , 3 , 2011-02-02 10:10
100 , ABC , 1 , 2011-02-04 12:15
101 , XYZ , 2 , 2011-02-03 10:12
101 , XYZ , 3 , 2011-02-04 16:13
For each CNO i want last 2 records based on the ENTRY_TIMESTAMP. The result should be as follows.
CNO CNAME RISKRATINGS ENTRY_TIMESTAMP
100 , ABC , 2 , 2011-02-03 10:15
100 , ABC , 1 , 2011-02-04 12:15
101 , XYZ , 2 , 2011-02-03 10:12
101 , XYZ , 3 , 2011-02-04 16:13
Your inputs are greatly appreciated.
-
- Participant
- Posts: 19
- Joined: Sat Dec 19, 2009 8:50 am
- Location: Chennai
-
- Participant
- Posts: 342
- Joined: Tue Nov 04, 2008 10:38 am
- Location: Chennai, India
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 19
- Joined: Sat Dec 19, 2009 8:50 am
- Location: Chennai
Define three Stage variables SV1,SV2 and SV3.
Initialize Values for Stage Variables:
SV2=$
Derivation for Stage variables:
SV1= InputCNO
SV2= If SV2='$' Then '1' Else (If SV3=SV1 Then SV2+1 Else '1')
SV3= InputCNO
Write a Constraint at Transformer level as follows.
SV2<3
There could be so many ways to do it. This is one way.
NOTE: you need to execute the transformer as "Sequential Mode"
Initialize Values for Stage Variables:
SV2=$
Derivation for Stage variables:
SV1= InputCNO
SV2= If SV2='$' Then '1' Else (If SV3=SV1 Then SV2+1 Else '1')
SV3= InputCNO
Write a Constraint at Transformer level as follows.
SV2<3
There could be so many ways to do it. This is one way.
NOTE: you need to execute the transformer as "Sequential Mode"
Cheers
Ravi K
Ravi K
-
- Participant
- Posts: 19
- Joined: Sat Dec 19, 2009 8:50 am
- Location: Chennai
-
- Participant
- Posts: 48
- Joined: Wed Jun 01, 2005 7:10 am
I am revising the code with meaning full names for easy understandability.
Define three Stage variables CurrentVal,Counter and PreviousVal.
CurrentVal=> InputCNO
Counter=> If CurrentVal=PreviousVal Then Counter+1 Else 1
PreviousVal=> InputCNO
Write a Constraint at Transformer level as follows.
Counter<3
Thanks Craig making the forum more meaning full.
Define three Stage variables CurrentVal,Counter and PreviousVal.
CurrentVal=> InputCNO
Counter=> If CurrentVal=PreviousVal Then Counter+1 Else 1
PreviousVal=> InputCNO
Write a Constraint at Transformer level as follows.
Counter<3
Thanks Craig making the forum more meaning full.
Cheers
Ravi K
Ravi K
No problem... one last nitpick, however.
Best practice is a common prefix on stage variables so they are easily recognized when referenced elsewhere, much like you are all doing for job parameters and the like, yes?
I use "sv" so would do something more like this:
Best practice is a common prefix on stage variables so they are easily recognized when referenced elsewhere, much like you are all doing for job parameters and the like, yes?
I use "sv" so would do something more like this:
Code: Select all
svCurrentVal=> InputCNO
svCounter=> If svCurrentVal=svPreviousVal Then svCounter+1 Else 1
svPreviousVal=> InputCNO
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers