scb2376


I need to simulate cursor-type (groan) behavior in a dataset and am wondering if this is possible in the foreach task. Example - The user has the need to go through the data row-by-row, and if a certain value is missing in row 10 then go back to row 8, grab a value from that row, and plug it in the missing column in row 10. Then move on to row 11.

Is there a way to make the foreach ADO enumerator travel backwards Is there a way to do this that will not be awfully inefficient Any suggestions out there would be welcome.

I've advocated for set-based updates, and these simply aren't an option, as each successive row depends on the updates that may have happened above it in the sequence. Unless I hear of any other ideas out there I have to move forward with this sequential type operation.




Re: Backwards in a foreach for ADO?

EWisdahl


This sounds like a script task to me... I don't believe that there is an effecient way to do this (if at all) with a for each loop...







Re: Backwards in a foreach for ADO?

scb2376

That's the headache I'm having - I don't see a good way to do this period, from a SQL/SSIS/relational perspective.






Re: Backwards in a foreach for ADO?

jwelch

Not sure if this would meet your needs, but you can use a script transform to buffer rows. You'd have to create some structure to store the data in (an array or dataset would work) and then you can access the rows in any order you wish.




Re: Backwards in a foreach for ADO?

scb2376

Sounds intriguing - do you happen to have an example handy