Hi,
I need help with below problem I am getting,
All data in file is in sorted in order on 4 columns (S_NO, VC_NO, CITY, DATE ),
I am trying to pull first record from combination of three keys (S_NO, VC_NO, CITY), when I try to use hash file stage it is pulling correct key combination but not the first record I need, let me give a example,
Example:
INPUT RECORDS:
S_NO | VC_NO | CITY| DATE|
1001 | X1002 | CITY1 | 2005/04/22
1001 | X1002 | CITY1 | 2001/05/01
1002 | X2002 | CITY2 | 2005/06/21
1003 | X3002 | CITY3 | 2005/04/22
1003 | X3002 | CITY3 | 2004/01/05
OUT RECORDS:
S_NO | VC_NO | CITY| DATE|
1002 | X2002 | CITY2 | 2005/06/21
1001 | X1002 | CITY1 | 2001/05/01
1003 | X3002 | CITY3 | 2005/04/22
This is what I am getting when I use hash stage with key combination of (S_NO, VC_NO, CITY)
What I need in output file is:
S_NO | VC_NO | CITY| DATE|
1001 | X1002 | CITY1 | 2005/04/22
1002 | X2002 | CITY2 | 2005/06/21
1003 | X3002 | CITY3 | 2005/04/22
Thank you,
Ashok
help needed with hash file with key combinations
Moderators: chulett, rschirm, roy
You need to understand that hash files do not support duplicate key combinations and resolve all differences via Destructive Overwrite. This means that the last version of the key written to the hash is the winner and the one that you'll pull out later.
Resort your data such that the desired 'first' key combination record is written to the hash last and you'll get back your needed output.
Resort your data such that the desired 'first' key combination record is written to the hash last and you'll get back your needed output.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hi,
Sort the input data using the key columns and declare 2 stage variables for each key column one would hold previous rec value and other one holds current rec value. Prev rec value would be null when you read the first rec and you need to handle this when the values are assigned to that variable. Have the constraint in the transformer that write the output rec if current & prev row value is different. By this method you can avoid writing the subsequent records for the same key.
HTWH.
Regards
Saravanan
Sort the input data using the key columns and declare 2 stage variables for each key column one would hold previous rec value and other one holds current rec value. Prev rec value would be null when you read the first rec and you need to handle this when the values are assigned to that variable. Have the constraint in the transformer that write the output rec if current & prev row value is different. By this method you can avoid writing the subsequent records for the same key.
HTWH.
Regards
Saravanan
-
- Charter Member
- Posts: 199
- Joined: Tue Jan 18, 2005 2:50 am
- Location: India
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: