Tom Kyte (of course) has some solutions:
http://asktom.oracle.com/~tkyte/flat/index.html