KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to execute a stored procedure with 4D Open for Java
PRODUCT: 4D Open for JAVA | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: October 5, 2001

The following code will show you what to code in order to create a stored procedure with 4D Open for Java.

In this first example, given a 4D method named My4DMethod with a stack size of 32000 - this method can be launched in any instances. This method will also accept an alphaniumeric parameter ($1) named MyParameter.

opServerProcess executeOnProcess = new opServerProcess();
opVariableArray myVarArray = new opVariableArray(1);
executeOnProcess.mMethodName = new String("My4DMethod ");
executeOnProcess.mProcessName = new String("SP_Java");
executeOnProcess.mStackSize = 32000;
executeOnProcess.mUnique = 0;
myVarArray.mVariableArray[0].mData = new opData(ALPHANUMERIC,"MyParameter");
p.ExecuteOnServer(executeOnProcess, myVarArray);

Now, let's add one more parameter, a LONGINT parameter. Its value will be 5.

opServerProcess executeOnProcess = new opServerProcess();
opVariableArray myVarArray = new opVariableArray(2);
executeOnProcess.mMethodName = new String("My4DMethod ");
executeOnProcess.mProcessName = new String("SP_Java");
executeOnProcess.mStackSize = 32000;
executeOnProcess.mUnique = 0;
myVarArray.mVariableArray[0].mData = new opData(ALPHANUMERIC,"MyParameter");
myVarArray.mVariableArray[1].mData = new opData(LONGINTEGER,5);
p.ExecuteOnServer(executeOnProcess, myVarArray);