Passing an INPUT parameter requires several steps to provide a value as input to an application service procedure or user-defined function.

To pass an INPUT parameter:

  1. Create and initialize a variable for the parameter of the correct Java data type (see Create variables for parameters).
  2. Add the parameter to a ParamArray object (see Create a parameter array>).
  3. Run the procedure or user-defined function (see Run procedures and user-defined functions).

This example passes an INPUT integer parameter that does not support the Unknown value (?).

Example: Passing an INPUT parameter using the Java OpenAPI

// Connect to the application server
OpenAppObject dynAO = new OpenAppObject("asbroker1");

// Define and initialize the variable for the input parameter
int CustomerNumber = 33;

// Create the ParamArray
ParamArray parms = new ParamArray(1);

// Add the input parameter to the ParamArray
parms.addInteger(0, CustomerNumber, ParamArrayMode.INPUT);

// Run the procedure or user-defined function
dynAO.runProc("AddCustomer.p", parms);
...

This examples passes an INPUT integer parameter that supports the Unknown value (?).

Example: Passing an INPUT parameter as the Unknown value (?) using the Java OpenAPI

// Connect to the application server
OpenAppObject dynAO = new OpenAppObject("asbroker1");

// Define and initialize the variable for the input parameter
Integer CustomerNumber = new Integer(33);

// Code possibly affecting the value of CustomerNumber
...

//Set the Integer value for the input parameter 
//to null or an int based on the variable value
if (CustomerNumber.intValue() > 33)
   CustomerNumber = null;

// Create the ParamArray
ParamArray parms = new ParamArray(1);

// Add the input parameter to the ParamArray
parms.addInteger(0, CustomerNumber, ParamArrayMode.INPUT);

// Run the procedure or user-defined function
dynAO.runProc("AddCustomer.p", parms);
...