@SupportsBatching @SeeAlso(value=ConvertJSONToSQL.class) @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"sql","put","rdbms","database","update","insert","relational"}) @CapabilityDescription(value="Executes a SQL UPDATE or INSERT command. The content of an incoming FlowFile is expected to be the SQL command to execute. The SQL command may use the ? to escape parameters. In this case, the parameters to use must exist as FlowFile attributes with the naming convention sql.args.N.type and sql.args.N.value, where N is a positive integer. The sql.args.N.type is expected to be a number indicating the JDBC Type. The content of the FlowFile is expected to be in UTF-8 format.") @ReadsAttribute(attribute="fragment.identifier",description="If the <Support Fragment Transactions> property is true, this attribute is used to determine whether or not two FlowFiles belong to the same transaction.") @ReadsAttribute(attribute="fragment.count",description="If the <Support Fragment Transactions> property is true, this attribute is used to determine how many FlowFiles are needed to complete the transaction.") @ReadsAttribute(attribute="fragment.index",description="If the <Support Fragment Transactions> property is true, this attribute is used to determine the order that the FlowFiles in a transaction should be evaluated.") @ReadsAttribute(attribute="sql.args.N.type",description="Incoming FlowFiles are expected to be parametrized SQL statements. The type of each Parameter is specified as an integer that represents the JDBC Type of the parameter.") @ReadsAttribute(attribute="sql.args.N.value",description="Incoming FlowFiles are expected to be parametrized SQL statements. The value of the Parameters are specified as sql.args.1.value, sql.args.2.value, sql.args.3.value, and so on. The type of the sql.args.1.value Parameter is specified by the sql.args.1.type attribute.") @ReadsAttribute(attribute="sql.args.N.format",description="This attribute is always optional, but default options may not always work for your data. Incoming FlowFiles are expected to be parametrized SQL statements. In some cases a format option needs to be specified, currently this is only applicable for binary data types, dates, times and timestamps. Binary Data Types (defaults to \'ascii\') - ascii: each string character in your attribute value represents a single byte. This is the format provided by Avro Processors. base64: the string is a Base64 encoded string that can be decoded to bytes. hex: the string is hex encoded with all letters in upper case and no \'0x\' at the beginning. Dates/Times/Timestamps - Date, Time and Timestamp formats all support both custom formats or named format (\'yyyy-MM-dd\',\'ISO_OFFSET_DATE_TIME\') as specified according to java.time.format.DateTimeFormatter. If not specified, a long value input is expected to be an unix epoch (milli seconds from 1970/1/1), or a string value in \'yyyy-MM-dd\' format for Date, \'HH:mm:ss.SSS\' for Time (some database engines e.g. Derby or MySQL do not support milliseconds and will truncate milliseconds), \'yyyy-MM-dd HH:mm:ss.SSS\' for Timestamp is used.") @WritesAttributes(value=@WritesAttribute(attribute="sql.generated.key",description="If the database generated a key for an INSERT statement and the Obtain Generated Keys property is set to true, this attribute will be added to indicate the generated key, if possible. This feature is not supported by all database vendors.")) public class PutSQL extends AbstractSessionFactoryProcessor
Constructor and Description |
---|
PutSQL() |
Modifier and Type | Method and Description |
---|---|
void |
constructProcess() |
java.util.Set<Relationship> |
getRelationships() |
protected java.util.List<PropertyDescriptor> |
getSupportedPropertyDescriptors()
Allows subclasses to register which property descriptor objects are
supported.
|
void |
onTrigger(ProcessContext context,
ProcessSessionFactory sessionFactory)
The method called when this processor is triggered to operate by the
controller.
|
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
protected java.util.List<PropertyDescriptor> getSupportedPropertyDescriptors()
AbstractConfigurableComponent
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
public java.util.Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
@OnScheduled public void constructProcess()
public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
Processor
The method called when this processor is triggered to operate by the
controller. In the absence of the TriggerSerially
annotation,
this method may be called concurrently from different threads.
When this method is called depends on how this processor is
configured within a controller to be triggered (timing or event
based).
context
- provides access to convenience methods for obtaining
property values, delaying the scheduling of the processor, provides
access to Controller Services, etc.sessionFactory
- provides access to a ProcessSession
, which
can be used for accessing FlowFiles, etc.ProcessException
- if processing did not complete normally though
indicates the problem is an understood potential outcome of processing.
The controller/caller will handle these exceptions gracefully such as
logging, etc.. If another type of exception is allowed to propagate the
controller may no longer trigger this processor to operate, as this would
indicate a probable coding defect.