Wednesday, October 24, 2018

Dump VO query and it’s parameter with their values


import oracle.jbo.VariableValueManager;
import oracle.jbo.Variable;

public void dumpQueryAndParameters()
{
    // get the query in it's current state
    String lQuery = getQuery();
    //get Valriables
    VariableValueManager lEnsureVariableManager = ensureVariableManager();
    Variable[] lVariables = lEnsureVariableManager.getVariables();
    int lCount = lEnsureVariableManager.getVariableCount();
    // Dump query
    System.out.println("---query--- " + lQuery);
    // if variables found dump them
    if (lCount > 0)
    {
        System.out.println("---Variables:");
        for (int ii = 0; ii < lCount; ii++)
        {
            Object lObject = lEnsureVariableManager.getVariableValue(lVariables[ii]);
            System.out.println("  --- Name: " + lVariables[ii].getName() + " Value: " +
                               (lObject != null ?  lObject.toString() : "null"));
        }
    }
}


You can overwrite the executeQuery() method of the ViewObjectImpl class and call the method above like

@Override
public void executeQuery()
{
    dumpQueryAndParameters();
    super.executeQuery();
}

No comments:

Post a Comment