Skip Headers

# Using an Output Parameter Event

Previous

Next

TopLink manages output parameter events for databases that support them. For example, if a stored procedure returns an error code that indicates that the application wants to check for an error condition, TopLink raises the session event `OutputParametersDetected` to allow the application to process the output parameters.

Stored Procedure with Reset Set and Output Parameter Error Code

    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("READ_EMPLOYEE");
    call.addNamedArgument("EMP_ID");
    call.addNamedOutputArgument(
        "ERROR_CODE",  // procedure parameter name
        "ERROR_CODE",  // out argument field name
        Integer.class  // Java type corresponding to type returned by procedure
    );
    call.useNamedCursorOutputAsResultSet("RESULT_SET");
    ReadObjectQuery query = new ReadObjectQuery();
    query.setCall(call);
    query.addArgument("EMP_ID");
    ErrorCodeListener listener = new ErrorCodeListener();
    session.getEventManager().addListener(listener);
    Vector args = new Vector();
    args.addElement(new Integer(44));
    Employee employee = (Employee)session.executeQuery(query, args);