LarrySteele
Programmer
Sorry if the subject is a bit vague, but I had a hard time creating one that accurately reflects what I'm trying to accomplish.
The scenario is this: I'll be receiving a file every day with updates to contracts. The data we receive needs a LOT of processing. Since it's not under our control, there's not a lot we can do with the quality of data in. If we press them, they will make changes, but the cost in time/money is beyond what the business is willing to pay. No worries, I've got most of it figured out, but there's one piece where I hit a slow down.
These contracts have start and dates. When either of these two dates change between our latest record and the new record, I need to take action. What I need to do is compare the new start date with the old end date. If new start date is just one day after the old end date, then they extended the contract and we'll actually use the old start date as the new start date.
[tt]
OLD RECORD.......................................
ORDER_NBR START_DATE END_DATE
5 01/01/2009 06/30/2009
NEW RECORD.(NEW START = OLD END +1 {EXTENSION})..
ORDER_NBR START_DATE END_DATE
5 07/01/2009 12/31/2009
INSERT RECORD....................................
ORDER_NBR START_DATE END_DATE
5 01/01/2009 12/31/2009
[/tt]
So, what I need to do is walk through our working table, and compare its start date to the end date for the current record in our data table. If new start = old end + 1, then extend. If new start > old end + 1, then we route the record to an error table. Otherwise, we take the dates given.
I'm pretty sure that I'll be using one or two cursors, but for some reason, just can't quite wrap my brain around what's required to set up the comparison, especially since I need to make my comparisons grouped by order numbers.
Any suggestions would be appreciated.
It helps to see real names, so here they are:
[tt]
Working table:
CNT_FIELDLASS
-ORDER_NBR
-START_DATE
-END_DATE
Data table:
CNT_DATA
-ORDER_NBR
-START_DATE
-END_DATE
[/tt]
Production system is on 11g, development is on 9i.
Thanks in advance,
Larry
The scenario is this: I'll be receiving a file every day with updates to contracts. The data we receive needs a LOT of processing. Since it's not under our control, there's not a lot we can do with the quality of data in. If we press them, they will make changes, but the cost in time/money is beyond what the business is willing to pay. No worries, I've got most of it figured out, but there's one piece where I hit a slow down.
These contracts have start and dates. When either of these two dates change between our latest record and the new record, I need to take action. What I need to do is compare the new start date with the old end date. If new start date is just one day after the old end date, then they extended the contract and we'll actually use the old start date as the new start date.
[tt]
OLD RECORD.......................................
ORDER_NBR START_DATE END_DATE
5 01/01/2009 06/30/2009
NEW RECORD.(NEW START = OLD END +1 {EXTENSION})..
ORDER_NBR START_DATE END_DATE
5 07/01/2009 12/31/2009
INSERT RECORD....................................
ORDER_NBR START_DATE END_DATE
5 01/01/2009 12/31/2009
[/tt]
So, what I need to do is walk through our working table, and compare its start date to the end date for the current record in our data table. If new start = old end + 1, then extend. If new start > old end + 1, then we route the record to an error table. Otherwise, we take the dates given.
I'm pretty sure that I'll be using one or two cursors, but for some reason, just can't quite wrap my brain around what's required to set up the comparison, especially since I need to make my comparisons grouped by order numbers.
Any suggestions would be appreciated.
It helps to see real names, so here they are:
[tt]
Working table:
CNT_FIELDLASS
-ORDER_NBR
-START_DATE
-END_DATE
Data table:
CNT_DATA
-ORDER_NBR
-START_DATE
-END_DATE
[/tt]
Production system is on 11g, development is on 9i.
Thanks in advance,
Larry