View previous topic :: View next topic
|
Author |
Message |
manoopatil
New User
Joined: 07 Dec 2003 Posts: 56 Location: Montreal
|
|
|
|
I need to sort the input given in the following format.
Code: |
ACCENURE1 1847709 ACCENURE1
ACCENURE1 0222139 ACCENURE1
ACCENURE1 41T6020707 ACCENURE1
ACCENURE1 70N6037226 ACCENURE1
ACCENURE1 08SQCA101384NBWK 0222139
ACCENURE1 5064449120 847709 1847709
ACCENURE1 05DHAT858102BLCA 285250 41T6020707
ACCENURE1 999 285250 41T6020707
ACCENURE1 05DHAT858103BLCA 285250 41T6020707
ACCENURE1 999 354035 70N6037226
ACCENURE1 01IPCD875986 354035 70N6037226
ACCENURE1 DG0054 285250 999
ACCENURE1 DG0060 285250 999
ACCENURE1 DG0001 354035 999
|
The records in input are sorted by first column - Master Cust. and fourth column Parent Name. second and third columns are Child Name and Sequence Number respectively.
The output is required in the following format with following rules
Code: |
ACCENURE1 0222139 ACCENURE1
ACCENURE1 08SQCA101384NBWK 0222139
ACCENURE1 1847709 ACCENURE1
ACCENURE1 5064449120 847709 1847709
ACCENURE1 41T6020707 ACCENURE1
ACCENURE1 05DHAT858102BLCA 285250 41T6020707
ACCENURE1 05DHAT858103BLCA 285250 41T6020707
ACCENURE1 999 285250 41T6020707
ACCENURE1 DG0054 285250 999
ACCENURE1 DG0060 285250 999
ACCENURE1 70N6037226 ACCENURE1
ACCENURE1 01IPCD875986 354035 70N6037226
ACCENURE1 999 354035 70N6037226
ACCENURE1 DG0001 354035 999
|
1. In output first record is sorted child with parent same as master cust.
2. The next record should one where parent is same as child in previous
record i.e. 0222139
3. If there is no record with parent equal to child in previous record then
record with parent equal to parent in previous record should come.
4. Also note '999' is a child under two different parents. In one place
sequence number is - 285250 where as in another place the sequence
number is 354035. As we can see the records with same sequence
number should be in sequence subject to the parent child relationship.
5. There can be multiple master cust in the input file. So records for each
master cust should be together with the sequence as above.
I know its a bit complicated to understand. Please let me know if you have some ideas to make it simpler
Thank you
-Manohar |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I know its a bit complicated to understand |
Manohar,
You feel that as "a bit"?. One really need to be patient to understand your requirement. What process is generating this file? Is it not possible to enforce these rules while writing the file?
Referring to your 3rd point, if 0222139 was not present as a "Parent Name" for any other records, what would be your 2nd record in output? |
|
Back to top |
|
|
manoopatil
New User
Joined: 07 Dec 2003 Posts: 56 Location: Montreal
|
|
|
|
Hi Arun,
I agree with you that one has to be really patient to understand the requirement. And thank you for taking interest in the post.
The file is getting generated from the SQL query in a program. The changes to the program are going to be costly and hence the option of using SORT or other utility is being explored.
Referring to the 3rd point, if 0222139 was not present as a "Parent Name" in any other records, then following would be 2nd record in the output.
Code: |
ACCENURE1 1847709 ACCENURE1
|
Please let me know in case of any question
Appreciate your help
Thanks
-Manohar |
|
Back to top |
|
|
|