Release 10.1A: OpenEdge Development:
Java Open Clients

> ## Non-persistent Procedure Sample

> Suppose you want to run a non-persistent procedure, `AddCustomer.p`, with the following definition:

> Sample non-persistent procedure 4GL 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.

> You might write the following client code to run it:

> OpenAPI code to run the non-persistent procedure sample
>     import com.progress.open4gl.javaproxy.*;
>     import com.progress.open4gl.Parameter;
>     public class sampleClient
>     {
>       private static final java.lang.String tName = new String( "KM_client" );
>       public static void nonPersistentProcedure()
>       {
>         try  // To catch all exceptions
>         {
>           // Connect to the AppServer
>           Connection myConn = new Connection("","","");
>           OpenAppObject dynAO = new OpenAppObject(myConn, "asbroker2");
>           // Create the parameters
>           String CustName = "abc";
>           String phone = "999-555-1234";
>           String email = "me@foo.com";
>           Integer CustomerNumber;
>           // Create a place for RETURN-VALUE
>           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 - notice the value is null
>           parms.addInteger(3, null, ParamArrayMode.OUTPUT);
>           // Run the procedure
>           dynAO.runProc("AddCustomer.p", parms);
>           // Get output parameters - Returned as Object, so must cast
>           CustomerNumber = (Integer) parms.getOutputParameter(3);
>           // Get RETURN-VALUE - Will return null for AddCustomer() procedure
>           retVal = (String)(parms.getProcReturnString());
>           dynAO._release();
>         } // try to catch all unexpected exceptions
>         catch ( Exception e )
>         {
>             System.out.println("Exception in sample1()");
>             System.out.println("Exception Message: " + e.getMessage());
>             e.printStackTrace();
>         }
>       }
>     } // class

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095