Skip Headers

# Specifying an Input Parameter

Previous

Next

In Example: Stored Procedure Call with an Input Parameter, you specify the parameter `POSTAL_CODE` as an input parameter using the `StoredProcedureCall` method `addNamedArgument`, and you can specify the value of the argument using method `addNamedArgumentValue`.

Stored Procedure Call with an Input Parameter

    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("CHECK_VALID_POSTAL_CODE");
    call.addNamedArgument("POSTAL_CODE");
    call.addNamedArgumentValue("POSTAL_CODE", "L5J1H5");
    call.addNamedOutputArgument(
        "IS_VALID",    // procedure parameter name
        "IS_VALID",    // out argument field name
        Integer.class  // Java type corresponding to type returned by procedure
    );
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    Number isValid = (Number)session.executeQuery(query);