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 : Non-persistent procedure sample
 

Non-persistent procedure sample

The following example shows a non-persistent procedure, AddCustomer.p.
Sample non-persistent procedure ABL for the OpenAPI
DEFINE INPUT PARAMETER CustName AS CHARACTER.
DEFINE INPUT PARAMETER phone AS CHARACTER.
DEFINE INPUT PARAMETER email AS CHARACTER.
DEFINE OUTPUT PARAMETER CustomerNumber AS INTEGER.
The following example shows an OpenAPI code to run a non-persistent procedure.
OpenAPI code to run a non-persistent procedure
namespace BigOrderInfoClient    {

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

  public class samplecode  {

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

      // Set Session model for state-free
      myConn.SessionModel = 1;

      // Create the parameters
      System.String CustName = "abc";
      System.String phone = "999-555-1234";
      System.String email = "me@foo.com";
      System.Int32 outValue;

      // Create a place for RETURN-VALUE
      System.String retVal;

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

      // Set up input parameters
      parms.AddCharacter(0, CustName, ParamArrayMode.INPUT);
      parms.AddCharacter(1, phone, ParamArrayMode.INPUT);
      parms.AddCharacter(2, email, ParamArrayMode.INPUT);

      // Set up Out parameters
      parms.AddInteger(3, null, ParamArrayMode.OUTPUT);

      // Run the procedure
      openAO.RunProc("AddCustomer.p", parms);

      // Get output parameters - use holder to handle unknown value
      outValue = (System.Int32)parms.GetOutputParameter(3);

      // Get RETURN-VALUE. Will return null for AddCustomer( ) procedure
      retVal = (System.String)parms.ProcReturnString;
      openAO.Dispose( );
    }
  }
}