JDBaccess API 1.0

com.jdbaccess.da
Interface Procedure

All Superinterfaces:
Call, DataAccess

public interface Procedure
extends Call

Interface for procedure calls. It extends the interface Call.

Example:
   Procedure procedure = DAReader.getProcedure(t);
   ArrayList params = new ArrayList();
   params.add(new Integer(4711));
   ArrayList outputParamTypes = new ArrayList();
   outputParamTypes.add("varchar");
   outputParamTypes.add("numeric");
   outputParamTypes.add("cursor");
   outputParamTypes.add("cursor"); 
   procedure.setProcedureName("prc_addSalaryPercent");
   procedure.setModuleName("pkg_employee");
   procedure.setParameters(params);
   procedure.setOutputParamTypes(outputParamTypes);
   ArrayList outputParams = (ArrayList) procedure.execute();
   String success = (String) outputParams.get(0);
   // first result: employees before execution of procedure
   CallResult result1 = procedure.getResult(1);
   ArrayList elems1 = result1.getAllElements();
   // second result: employees after execution of procedure
   CallResult result2 = procedure.getResult(2); 
   ArrayList elems2 = result2.getAllElements();
   // count of all updated rows of this procedure
   Long updateCount = procedure.getSize(); 
   procedure.end();
 


Method Summary
 java.lang.Object execute()
          Execute the procedure and return an ArrayList of all output paramaters or one ouput paramter as an object if only one output parameter exists the
 java.util.ArrayList getOutputParams()
          Get the output parameters of the procedure.
 java.lang.String getProcedureName()
          Get the name of the procedure.
 CallResult getResult(int resultPosition)
          Procedures could have one or more call results (selection results).
 void setOutputParamTypes(java.util.ArrayList outputParamTypes)
          Set the output parameter types of the procedure.
 void setProcedureName(java.lang.String procedureName)
          Set the name of the procedure.
 
Methods inherited from interface com.jdbaccess.da.Call
getModuleName, setModuleName, setReadLobsFull
 
Methods inherited from interface com.jdbaccess.da.DataAccess
end, getName, getObjectType, getPackageName, getSize, getSql, setName, setObjectType, setPackageName, setParameters, setSql, toString
 

Method Detail

execute

java.lang.Object execute()
                         throws ApplicationException
Execute the procedure and return an ArrayList of all output paramaters or one ouput paramter as an object if only one output parameter exists the

Returns:
an ArrayList of all output paramaters or one ouput paramter as an object if only one output parameter exists the
Throws:
ApplicationException

getOutputParams

java.util.ArrayList getOutputParams()
Get the output parameters of the procedure.

Returns:
all the output parameters of the procedure (execept of type CallResult: see getResult(int pos)).

getProcedureName

java.lang.String getProcedureName()
Get the name of the procedure.

Returns:
the name of the procedure. e.g. prc_updateSalaryById

setProcedureName

void setProcedureName(java.lang.String procedureName)
Set the name of the procedure.

Parameters:
procedureName - name of the procedure to set. e.g. prc_updateSalaryById

setOutputParamTypes

void setOutputParamTypes(java.util.ArrayList outputParamTypes)
Set the output parameter types of the procedure.

Parameters:
outputParamTypes - The output parameter types as an ArrayList. They have to be in the same order than definded in the database system procedure. In Oracle a special type "Cursor" has to be set if the database procedure defines a "ref cursor" as an output parameter. In MySql this is not necessary.

getResult

CallResult getResult(int resultPosition)
                     throws ApplicationException
Procedures could have one or more call results (selection results). You get them by the appropriate position defined in the procedure. In Oracle call results have to be defined as output parameter types (with setOutputParamTypes) before the Oracle procedure can be executed. In MySql call results can only be accessed in the right order. If you access for example the second result at first (yourProcedure.getResult(2)) and after that try to access the first result (yourProcedure.getResult(1)) you would get an error message.

Parameters:
resultPosition -
Returns:
call result at that result position
Throws:
ApplicationException

JDBaccess API 1.0

Copyright © 2005-2006 JDBaccess.com, Königsweg 210, D-14129 Berlin, Germany. All Rights Reserved.