All that money was spent to reduce the number of shares, so that earnings-per-share increased, because that is what the exec bonuses were based on. Under those incentives, management decided it better to spend it that way than, for example, actually investing in the well-being of the business or employees.
Oracle's failure is the result of the incentives management was given. They met those incentives, which cost the rest of the company dearly. Imagine a different universe where Oracle's incentives were "increase earnings" instead of "increase earnings per share" - Oracle in that universe is doing fine.
Oh, and BTW, I just lifted this post from IBM's page and replaced the word IBM with Oracle... No need to change anything else.