Based on http://www.oracle.com/technetwork/issue-archive/2011/11-nov/o61sql-512018.html