private static void getExecutionPlansFromDB(
            List<DeltaSQLStatementSnapshot> sqlStatementsToLoad,
            PreparedStatement sqlTextStatement) throws SQLException {

        ResultSet executionPlansResultSet = sqlTextStatement.executeQuery();

        // use a definitely not used (invalid) SQL ID and ChildId to get started
        String lastSqlId = "";
        int lastInstanceNumber = -1;
        int lastChildNumber = -1;
        ExecutionPlan lastExecutionPlan = null;
        while (executionPlansResultSet.next()) {

            int resultIndex = 1;
            String currentSqlId = executionPlansResultSet.getString(resultIndex++);
            int currentInstanceNumber = executionPlansResultSet.getInt(resultIndex++);
            int currentChildNumber = executionPlansResultSet.getInt(resultIndex++);

            // find the SQL statement with this address
            DeltaSQLStatementSnapshot deltaSQLStatementSnapshot =
                    SQLHelper.findSQLStatementWithSqlId(sqlStatementsToLoad, currentSqlId);
            if (deltaSQLStatementSnapshot == null) {
                // there is no SQL statement with this address in the list
                // this should never happen...
                throw new RuntimeException(
                        "Fatal Exception: Oracle returned a result not being asked for.");
            }

            ExecutionPlanStep newStep = new ExecutionPlanStep(
                    // id
                    executionPlansResultSet.getInt(resultIndex++),
                    // parent id
                    executionPlansResultSet.getInt(resultIndex++),
                    // operation
                    executionPlansResultSet.getString(resultIndex++),
                    // options
                    executionPlansResultSet.getString(resultIndex++),
                    // objectOwner
                    executionPlansResultSet.getString(resultIndex++),
                    // objectName
                    executionPlansResultSet.getString(resultIndex++),
                    // depth
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // position
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // cost
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // cardinality
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // bytes
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // cpuCost
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // ioCost
                    executionPlansResultSet.getBigDecimal(resultIndex++),
                    // accessPredicates
                    executionPlansResultSet.getString(resultIndex++),
                    // filterPredicates
                    executionPlansResultSet.getString(resultIndex++));

            if (lastSqlId.equals(currentSqlId)
                    && lastInstanceNumber == currentInstanceNumber
                    && lastChildNumber == currentChildNumber) {
                // a new step for the current child of the current instance of the current SQL statement
                if (!lastExecutionPlan.getParentStep()
                        .insertStepToCorrectPositionInStepOrChilds(newStep)) {
                    // the new step could not be integrated into the execution plan.
                    // this should never happen...
                    throw new RuntimeException(
                            "Fatal Exception: Oracle returned a step of an execution plan that could not be integrated.");
                }
            } else {
                // a new execution plan for the current address/SQL statement or a new address/SQL statement
                // no matter - in both cases we need a new execution plan for the current statement
                lastExecutionPlan = new ExecutionPlan(currentInstanceNumber,
                        currentChildNumber,
                        currentSqlId);
                lastExecutionPlan.setParentStep(newStep);
                deltaSQLStatementSnapshot.getSqlStatement().addExecutionPlan(lastExecutionPlan);
            }

            lastSqlId = currentSqlId;
            lastInstanceNumber = currentInstanceNumber;
            lastChildNumber = currentChildNumber;
        }
    }