Release 10.1A: OpenEdge Development:
Java Open Clients

> ## Persistent Procedure Sample

> Suppose you want to run a persistent procedure, `CustomerOrder.p`, with the following definition, containing a user-defined function:

> Sample persistent procedure 4GL for the OpenAPI
>     DEFINE INPUT PARAMETER custNum AS INTEGER NO-UNDO.
>     ...
>     FUNCTION GetTotalOrdersByNumber RETURNS INTEGER (threshold AS DECIMAL):
>     ...
>     END.
>     ...

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

> OpenAPI code to run the 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 persistentProcedure()
>       {
>         try  // To catch all exceptions
>         {
>           // Connect to the AppServer
>           Connection myConn = new Connection("","","");
>           OpenAppObject dynAO = new OpenAppObject(myConn, "asbroker2");
>           // Run the persistent Procedure
>           // First set up parameters
>           ParamArray parms = new ParamArray(1);
>           int custNum = 3;
>           // Set up input parameters
>           parms.addInteger(0, custNum, ParamArrayMode.INPUT);
>           // Run procedure
>           OpenProcObject dynPO = dynAO.createPO("OrderInfo/CustomerOrder.p",
>                                                 parms);
>           // Call UDF
>           // First set up parameters
>           Integer retVal;
>           java.math.BigDecimal threshold = new java.math.BigDecimal(1000);
>           parms.clear(); // Clear for reuse
>           // Set up input parameters
>           parms.addDecimal(0, threshold, ParamArrayMode.INPUT);
>           // Set up return type
>           parms.setReturnType(Parameter.PRO_INTEGER);
>           // Run procedure
>           dynPO.runProc("GetTotalOrdersByNumber", parms);
>           // Get return value
>           retVal = (Integer)(parms.getReturnValue());
>           dynPO._release();
>           dynAO._release();
>         } // try to catch all unexpected exceptions
>         catch ( Exception e )
>         {
>             System.out.println("Exception in sample2()");
>             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