- java.lang.Object
-
- com.pervasive.datarush.operators.AbstractLogicalOperator
-
- com.pervasive.datarush.operators.CompositeOperator
-
- com.pervasive.datarush.operators.io.jdbc.JDBCOperator
-
- com.pervasive.datarush.operators.io.jdbc.AbstractWriteToJDBC
-
- com.pervasive.datarush.operators.io.jdbc.UpdateInJDBC
-
- All Implemented Interfaces:
ConnectionSettings
,LogicalOperator
,PipelineOperator<RecordPort>
,RecordPipelineOperator
public final class UpdateInJDBC extends AbstractWriteToJDBC implements RecordPipelineOperator
This operator updates the target table in a database by applying SQL update statements. This operator will additionally copy the used input to an output port that will contain an additional status field indicating whether the update succeeded for that row and how many rows in the target table were updated by it. The operator will use the input data rows to create database update statements. Values provided in the input data source will be used to update the target table values.Key fields
must be specified in the operator properties. Key field values will be used within generated database update statements. The updated fields may also be optionally set usingsetUpdateFields(String[])
. If unset will use all fields not already used as key fields.Initial
andfinal
SQL statements can be provided. The initial statement is run before any input data is handled. The final statement is executed after all input data has been processed. Note that theUpdateInJDBC
operator is parallelized. Each parallel instance will open a separate connection to the target database. To limit the number of database connections used by this operator, tune down the operator parallelism level. To set the parallelism level create anOperatorSettings
instance with maximum parallelism set to the wanted level. The operator settings can then be passed as a parameter to theLogicalGraph#add(com.pervasive.datarush.operators.LogicalOperator, OperatorSettings)
method.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.pervasive.datarush.operators.io.jdbc.AbstractWriteToJDBC
AbstractWriteToJDBC.AbstractWriteHelper, AbstractWriteToJDBC.AbstractWriteToJDBCWorker, AbstractWriteToJDBC.SqlWriteProperties
-
-
Field Summary
-
Fields inherited from class com.pervasive.datarush.operators.io.jdbc.AbstractWriteToJDBC
commitInterval, finalizeTableSQL, initializeTableSQL, input, isolationLevel, keyNames, renameMapping
-
-
Constructor Summary
Constructors Constructor Description UpdateInJDBC()
Default constructor.UpdateInJDBC(UpdateInJDBC other)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
compose(CompositionContext ctx)
Compose the body of this operator.RecordPort
getOutput()
Get the output port containing the statuses received from the database.String
getStatusField()
Get the name of the field that will contain the update status.String[]
getUpdateFields()
Get the names of the fields that will be updated.void
setStatusField(String statusField)
Set the name of the field that will contain the update status.void
setUpdateFields(String[] updateFields)
Set the names of the fields that will be updated.-
Methods inherited from class com.pervasive.datarush.operators.io.jdbc.AbstractWriteToJDBC
appendDelimited, buildDeleteStatement, buildInsertStatement, buildUpdateStatement, createDropTableSQL, createTruncateTableSQL, getCommitInterval, getFinalizeTableSQL, getInitializeTableSQL, getInput, getIsolationLevel, getKeyNameList, getKeyNames, getRenameMapping, guessTableName, setCommitInterval, setFinalizeTableSQL, setInitializeTableSQL, setIsolationLevel, setKeyNames, setRenameMapping
-
Methods inherited from class com.pervasive.datarush.operators.io.jdbc.JDBCOperator
getConnectionFactory, getDriverName, getErrorAction, getHostNames, getJDBCConnector, getPassword, getSqlWarningLimit, getTableName, getUrl, getUser, setConnectionFactory, setDriverName, setErrorAction, setHostNames, setHostNames, setJDBCConnector, setPassword, setSqlWarningLimit, setTableName, setUrl, setUser
-
Methods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperator
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.operators.LogicalOperator
disableParallelism, getInputPorts, getOutputPorts
-
Methods inherited from interface com.pervasive.datarush.operators.PipelineOperator
getInput
-
-
-
-
Constructor Detail
-
UpdateInJDBC
public UpdateInJDBC()
Default constructor.
-
UpdateInJDBC
public UpdateInJDBC(UpdateInJDBC other)
Copy constructor.- Parameters:
other
- the other instance ofWriteToJDBC
-
-
Method Detail
-
setStatusField
public void setStatusField(String statusField)
Set the name of the field that will contain the update status. Defaults to Updated.- Parameters:
statusField
- name of the status field in the output
-
getStatusField
public String getStatusField()
Get the name of the field that will contain the update status.- Returns:
- name of the status field in the output
-
setUpdateFields
public void setUpdateFields(String[] updateFields)
Set the names of the fields that will be updated. Includes all non key fields by default.- Parameters:
updateFields
- names of the fields that will be updated
-
getUpdateFields
public String[] getUpdateFields()
Get the names of the fields that will be updated.- Returns:
- names of the fields that will be updated
-
getOutput
public RecordPort getOutput()
Get the output port containing the statuses received from the database.- Specified by:
getOutput
in interfacePipelineOperator<RecordPort>
- Returns:
- output record port
-
compose
protected void compose(CompositionContext ctx)
Description copied from class:CompositeOperator
Compose the body of this operator. Implementations should do the following:- Perform any validation of configuration, input types, etc
- Instantiate and configure sub-operators, adding them to the provided context via
the method
OperatorComposable.add(O)
- Create necessary connections via the method
OperatorComposable.connect(P, P)
. This includes connections from the composite's input ports to sub-operators, connections between sub-operators, and connections from sub-operators output ports to the composite's output ports
- Specified by:
compose
in classCompositeOperator
- Parameters:
ctx
- the context
-
-