Passing an OUTPUT parameter requires several steps to provide a parameter as output from an application service procedure or user-defined function, then to get the value returned by the parameter.

To pass an OUTPUT parameter:

  1. Create and initialize a variable for the parameter of the correct .NET data type (see Create variables for parameters).
  2. Add the parameter to a ParamArray object (see Set up a parameter array).
  3. Run the procedure or user-defined function (see Run procedures and user-defined functions).
  4. Get the output value from the ParamArray (see Get OUTPUT parameter values).

Passing an OUTPUT parameter using the .NET OpenAPI

The following example passes an OUTPUT integer parameter that does not support the Unknown value (?).

// Define the variable for the output parameter
Int32 CustomerNumber;

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

// Set up output parameter - notice no variable is needed at this point
parms.AddInteger(0, null, ParamArrayMode.OUTPUT);

// Run the procedure
...

// Fill the output parameter
// The output value is always returned as an Object
// You need to cast the Object before assigning it.
CustomerNumber = (Int32) parms.GetOutputParameter(0);