Petrovich implementation in Oracle SQL