flux
Interface DatabaseStoredProcedureAction

All Superinterfaces:
Action, java.lang.Cloneable, DatabaseActionInfo, RuntimeDataMap, java.io.Serializable

public interface DatabaseStoredProcedureAction
extends DatabaseActionInfo

Calls a stored procedure and makes the results of the stored procedure, if any, available to the flow context.

For this purpose, the database connection available to the flow context can be used, or alternately, database connection information can be provided to connect to a data source or use a direct JDBC connection.

When this action runs, there are potentially two kinds of output: OUT parameters and a JDBC result set.

OUT parameters return data from the stored procedure after it is called. They must be registered before the stored procedure is called, and they are made available in the result object. If there are no OUT parameters registered, no outputs are made available. Not all stored procedures return data through OUT parameters.

Additionally, the stored procedure may return a JDBC result set. If it does, it is returned as a facade over a JDBC result set. The facade exposes the first row of data returned by the SQL SELECT statement. Each time the current execution flow context reaches this action again, the next row in the JDBC result set is fetched.

Finally, when the JDBC result set is exhausted, the result set is closed. The result set is also closed when the current execution flow context reaches a transaction break, since JDBC result sets must be closed before the open transaction commits.

Once the JDBC result set is closed, the next time the current execution flow context executes this action, the SQL SELECT statement is issued again, and the entire process repeats.

Open JDBC result sets are stored in a transient flow context variable whose name is referenced from DatabaseStoredProcedureAction.RESULT_SET_FLOW_CONTEXT_KEY.

Note: this action does not provide access to any returned JDBC result sets beyond the first one. Also, stored functions are not supported. Contact support@flux.ly if you would like either of these features added to this action.

The Database Stored Procedure Action returns its result in the flow context variable "RESULT". The following table contains more information on accessing and using the result.

Flow Context Variable Field Java Type Description
RESULTresultbooleanA boolean value indicating whether there are more results available in the underlying JDBC result set.
RESULToutParametersjava.util.List<java.lang.Object>A List representing the OUT parameters from the stored procedure call.
RESULTrowjava.util.List<java.lang.Object>A List representing the current row in the result set.

Author:
Copyright 2014 Flux Corporation. All rights reserved.

Nested Class Summary
static class DatabaseStoredProcedureAction.DatabaseStoredProcedureActionResult
          A facade over OUT parameters and a JDBC result set, which are returned after an SqlStoredProcedureAction runs.
 
Field Summary
static java.lang.String RESULT_SET_FLOW_CONTEXT_KEY
          The key to a flow context variable that may hold an open JDBC result set from a previous iteration over this action within the same transaction.
 
Method Summary
 Flow addFlow(Action action)
          The flow that is followed when this Database Stored Procedure Action fires.
 java.util.List<java.lang.Object> getParameters()
          Returns the parameters that are supplied to a stored procedure call.
 java.util.Map<java.lang.Integer,java.lang.Integer> getRegisteredInoutParameters()
          Returns positional and type information about this stored procedure's registered IN-OUT parameters.
 java.util.Map<java.lang.Integer,java.lang.Integer> getRegisteredOutParameters()
          Returns positional and type information about this stored procedure's registered OUT parameters.
 int getRegisteredOutParameterSqlType()
          Returns the registered OUT parameter's SQL type, taken from java.sql.Types, in the common case where there is only one registered OUT parameter and it is the last parameter in the stored procedure signature.
 int getStoredFunctionResultSqlType()
          If this stored procedure is a stored function, returns the stored function's result SQL type, taken from java.sql.Types.
 java.lang.String getStoredProcedureCall()
          Returns the signature of the stored procedure call that is used to invoke a stored procedure on a database.
 void setParameters(java.util.List<java.lang.Object> parameters)
          Sets the parameters that are supplied to a stored procedure call.
 void setRegisteredInoutParameters(java.util.Map<java.lang.Integer,java.lang.Integer> inoutParameters)
          Sets positional and type information about this stored procedure's registered IN-OUT parameters.
 void setRegisteredOutParameters(java.util.Map<java.lang.Integer,java.lang.Integer> outParameters)
          Sets positional and type information about this stored procedure's registered OUT parameters.
 void setRegisteredOutParameterSqlType(int sqlType)
          Sets the registered OUT parameter's SQL type, taken from java.sql.Types, in the common case where there is only one registered OUT parameter and it is the last parameter in the stored procedure signature.
 void setStoredFunctionResultSqlType(int sqlType)
          If this stored procedure is a stored function, sets the stored function's result SQL type, taken from java.sql.Types.
 void setStoredProcedureCall(java.lang.String storedProcedureCall)
          Sets the signature of the stored procedure call that is used to invoke a stored procedure on a database.
 
Methods inherited from interface flux.DatabaseActionInfo
getDataSource, getDataSourceInitialContextFactory, getDataSourceInitialContextPassword, getDataSourceInitialContextProviderUrl, getDataSourceInitialContextUsername, getDataSourcePassword, getDataSourceUsername, getJdbcDriver, getJdbcPassword, getJdbcUrl, getJdbcUsername, isBuiltinDatabaseConnectionUsed, setBuiltinDatabaseConnectionUsed, setDataSource, setDataSourceInitialContextFactory, setDataSourceInitialContextPassword, setDataSourceInitialContextProviderUrl, setDataSourceInitialContextUsername, setDataSourcePassword, setDataSourceUsername, setJdbcDriver, setJdbcPassword, setJdbcUrl, setJdbcUsername
 
Methods inherited from interface flux.Action
addFlow, addSignalFlow, clone, execute, getDescription, getFlows, getHiddenVariableNames, getJoinExpression, getName, getPostscript, getPostscriptLanguage, getPrescript, getPrescriptLanguage, getResultInfo, getSignalsToMonitor, getTimeoutBusinessInterval, getTimeoutBusinessIntervalNamespace, getTimeoutExpression, getVariableManager, isEndOfRun, isJoinPoint, isSkippable, isStartAction, isStartOfRun, isTransactionBreak, removeFlow, reset, setDescription, setElseFlow, setEndOfRun, setErrorFlow, setErrorFlowWithoutRollback, setErrorFlowWithRollback, setJoinExpression, setJoinPoint, setName, setPostscript, setPostscriptLanguage, setPrescript, setPrescriptLanguage, setSignalsToMonitor, setSkippable, setStartAction, setStartOfRun, setTimeoutBusinessInterval, setTimeoutBusinessIntervalNamespace, setTimeoutExpression, setTimeoutFlow, setTransactionBreak, verify, verifyOnClient
 
Methods inherited from interface flux.runtimedatamap.RuntimeDataMap
getRuntimeDataMap, setRuntimeDataMap
 

Field Detail

RESULT_SET_FLOW_CONTEXT_KEY

static final java.lang.String RESULT_SET_FLOW_CONTEXT_KEY
The key to a flow context variable that may hold an open JDBC result set from a previous iteration over this action within the same transaction.

See Also:
Constant Field Values
Method Detail

addFlow

Flow addFlow(Action action)
The flow that is followed when this Database Stored Procedure Action fires. Some stored procedures return a result set. To create a flow that is followed only when there is unconsumed result set data from the stored procedure call, call addFlow(Action, EngineHelper.useLastResult("result")) instead. To follow a flow after all result set data has been consumed, call DatabaseStoredProcedureAction.setElseFlow(action).

Specified by:
addFlow in interface Action
Parameters:
action - The flow that is followed when this Database Stored Procedure Action fires.
Returns:
The newly created flow.
See Also:
DatabaseStoredProcedureAction.DatabaseStoredProcedureActionResult, Action.addFlow(Action, String), EngineHelper.useLastResult(String)

getParameters

java.util.List<java.lang.Object> getParameters()
Returns the parameters that are supplied to a stored procedure call. The first element in the list corresponds to the first value in the SQL parameter list.

Returns:
The parameters that are supplied to a stored procedure call.

getRegisteredInoutParameters

java.util.Map<java.lang.Integer,java.lang.Integer> getRegisteredInoutParameters()
Returns positional and type information about this stored procedure's registered IN-OUT parameters. The map keys represent the 1-based index numbers of the stored procedure's IN-OUT parameters. The map values represent each IN-OUT parameter's SQL type, such as VARCHAR, taken from java.sql.Types.

For example, if this stored procedure has IN-OUT parameters in index positions 3 and 5, IN-OUT parameter 3 is of SQL type VARCHAR, and IN-OUT parameter 5 is of SQL type INTEGER, then the result map has two entries. The first entry maps 3 to java.sql.Types.VARCHAR. The second entry maps 5 to java.sql.Types.INTEGER.

Returns:
Positional and type information about this stored procedure's registered IN-OUT parameters. Does not return null.

getRegisteredOutParameters

java.util.Map<java.lang.Integer,java.lang.Integer> getRegisteredOutParameters()
Returns positional and type information about this stored procedure's registered OUT parameters. The map keys represent the 1-based index numbers of the stored procedure's OUT parameters. The map values represent each OUT parameter's SQL type, such as VARCHAR, taken from java.sql.Types.

For example, if this stored procedure has OUT parameters in index positions 3 and 5, OUT parameter 3 is of SQL type VARCHAR, and OUT parameter 5 is of SQL type INTEGER, then the result map has two entries. The first entry maps 3 to java.sql.Types.VARCHAR. The second entry maps 5 to java.sql.Types.INTEGER.

Returns:
Positional and type information about this stored procedure's registered OUT parameters. Does not return null.

getRegisteredOutParameterSqlType

int getRegisteredOutParameterSqlType()
Returns the registered OUT parameter's SQL type, taken from java.sql.Types, in the common case where there is only one registered OUT parameter and it is the last parameter in the stored procedure signature. This method is a simplified version of the getRegisteredOutParameters() method.

Returns:
The SQL type, taken from java.sql.Types, for the registered OUT parameter. If the last registered parameter is not an OUT parameter, returns -1.

getStoredFunctionResultSqlType

int getStoredFunctionResultSqlType()
If this stored procedure is a stored function, returns the stored function's result SQL type, taken from java.sql.Types. This method is a simplified version of the getRegisteredOutParameters() method.

Returns:
The SQL type, taken from java.sql.Types, if this stored procedure is a stored function. Otherwise, returns -1.

getStoredProcedureCall

java.lang.String getStoredProcedureCall()
Returns the signature of the stored procedure call that is used to invoke a stored procedure on a database.

Returns:
The signature of the stored procedure call that is used to invoke a stored procedure on a database.

setRegisteredInoutParameters

void setRegisteredInoutParameters(java.util.Map<java.lang.Integer,java.lang.Integer> inoutParameters)
Sets positional and type information about this stored procedure's registered IN-OUT parameters. The map keys represent the 1-based index numbers of the stored procedure's IN-OUT parameters. The map values represent each IN-OUT parameter's SQL type, such as VARCHAR, taken from java.sql.Types.

For example, if this stored procedure has IN-OUT parameters in index positions 3 and 5, IN-OUT parameter 3 is of SQL type VARCHAR, and IN-OUT parameter 5 is of SQL type INTEGER, then the input map has two entries. The first entry maps 3 to java.sql.Types.VARCHAR. The second entry maps 5 to java.sql.Types.INTEGER.

Parameters:
inoutParameters - Positional and type information about this stored procedure's registered IN-OUT parameters. A null map is treated the same as an empty map.

setRegisteredOutParameters

void setRegisteredOutParameters(java.util.Map<java.lang.Integer,java.lang.Integer> outParameters)
Sets positional and type information about this stored procedure's registered OUT parameters. The map keys represent the 1-based index numbers of the stored procedure's OUT parameters. The map values represent each OUT parameter's SQL type, such as VARCHAR, taken from java.sql.Types.

For example, if this stored procedure has OUT parameters in index positions 3 and 5, OUT parameter 3 is of SQL type VARCHAR, and OUT parameter 5 is of SQL type INTEGER, then the input map has two entries. The first entry maps 3 to java.sql.Types.VARCHAR. The second entry maps 5 to java.sql.Types.INTEGER.

Parameters:
outParameters - Positional and type information about this stored procedure's registered OUT parameters. A null map is treated the same as an empty map.

setRegisteredOutParameterSqlType

void setRegisteredOutParameterSqlType(int sqlType)
Sets the registered OUT parameter's SQL type, taken from java.sql.Types, in the common case where there is only one registered OUT parameter and it is the last parameter in the stored procedure signature. This method is a simplified version of the setRegisteredOutParameters() method.

Parameters:
sqlType - The SQL type, taken from java.sql.Types, for the registered OUT parameter.

setParameters

void setParameters(java.util.List<java.lang.Object> parameters)
Sets the parameters that are supplied to a stored procedure call. The first element in the list corresponds to the first value in the SQL parameter list.

Parameters:
parameters - The parameters that are supplied to a stored procedure call.

setStoredFunctionResultSqlType

void setStoredFunctionResultSqlType(int sqlType)
If this stored procedure is a stored function, sets the stored function's result SQL type, taken from java.sql.Types. This method is a simplified version of the setRegisteredOutParameters() method.

Parameters:
sqlType - The SQL type, taken from java.sql.Types, if this stored procedure is a stored function.

setStoredProcedureCall

void setStoredProcedureCall(java.lang.String storedProcedureCall)
Sets the signature of the stored procedure call that is used to invoke a stored procedure on a database.

Parameters:
storedProcedureCall - The signature of the stored procedure call that is used to invoke a stored procedure on a database.


© 2014 Flux Corporation. All rights reserved.