Try OpenEdge Now
skip to main content
.NET Open Clients
Using the Open Client .NET OpenAPI to Directly Access the AppServer : Sample .NET OpenAPI code : Persistent procedure sample
 

Persistent procedure sample

The following example shows a portion of code for a procedure, CustomerInfo.p, with a user-defined function.
Procedure CustomerInfo.p
DEFINE INPUT PARAMETER custNum AS INTEGER NO-UNDO.
...

FUNCTION GetTotalOrdersByNumber RETURNS INTEGER (threshold AS DECIMAL):
...
END.
...
The following example shows OpenAPI code that runs CustomerInfo.p as a persistent procedure.
OpenAPI code to run the persistent procedure
namespace BigOrderInfoClient  {

  using Progress.Open4GL;
  using Progress.Open4GL.Proxy;

  public class samplecode         {
    public static void PersistentProcedure( )  {
      // Connect to the AppServer
      Connection myConn = new Connection
                          ("AppServer://localhost/asbroker2", "", "", "");
      OpenAppObject openAO = new OpenAppObject(myConn, "mySvc");

      // Run the persistent procedure
      // First set up parameters
      ParamArray parms = new ParamArray(1);
      System.Int32 custNum = 3;

      // Set up input parameters
      parms.AddInteger(0, custNum, ParamArrayMode.INPUT);
      // Run procedure
      OpenProcObject openPO = openAO.CreatePO("OrderInfo/CustomerOrder.p",
                                              parms);

      // Call UDF
      // First set up parameters
      System.Decimal retVal;
      int Threshold = 1000;
      parms.Clear( ); // Clear ParamArray for next call

      // Set up input parameters
      parms.AddDecimal(0, Threshold, ParamArrayMode.INPUT);

      // Set up return type
      parms.ReturnType = Parameter.PRO_DECIMAL;

      // Run procedure
      openPO.RunProc("GetTotalOrdersByNumber", parms);

      // Get return value
      retVal = (System.Decimal)parms.ReturnValue;

      openPO.Dispose( );
      openAO.Dispose( );
    }
  }
}