You might also look at AskTom's solutions here: http://asktom.oracle.com/tkyte/flat/index.html