I lift this almost-quote out of the thread "Learning to play vs learning to concentrate" because that thread now is more about nervousness.
Playing parts correctly, but making random mistakes, at different places, when I play the whole piece, is part of my experience also.
I have thought a lot about this problem and its cause. What is failing? Is it concentration? Memory? Stamina?
Or, is it simply like this? We are still in the process of learning a piece. We have come so far that we can play each part correctly. However, playing each part correctly is still an effortful process, taxing our brains.
When we play parts separately, there is always a little break between each part, giving our brain a short moment of rest, but when we play the whole piece, it is taxing - taxing - taxing for the brain, and somewhere at a random place, our brain cannot keep it up any more and the fingers make a mistake.
Long story short - when we can play all parts correctly, are we simply not yet finished learning the piece? Is learning to play the whole piece the final stage of learning a piece? What do you think?