pfx-sql:insert
Inserts data to a database table.
Properties
Option | Type | Default | Description |
---|---|---|---|
| string |
| Defines a Data Source name. |
| string | Â | Defines a database table. |
| string | Â | Defines a data mapper. |
| integer | 5000 | Used for fetching from the database. |
| string | MYSQL | Defines an SQL dialect. Possible values are:
|
| string | Â | Defines business keys. |
| string | Â | Defines an output target for data in exchange. It can be stored in header, property or body. |
| string | Â | Defines an output target name for the target type header and property. Name of the exchange header, name of the exchange property. |
Examples
These examples of SQL insert using the pfx-sql component are quite straightforward. You only need to set a correct body and mapper.
Example of inserting rows from a CSV file to a POSTGRESQL database table:
Mapper:
<pfx:loadMapper id="orderReasonMapper" includeUnmappedProperties="false">
<pfx:groovy expression="body.ORDER_REASON == null || body.ORDER_REASON.length() == 0 ? '-' : body.ORDER_REASON" out="ORDER_REASON" />
<pfx:groovy expression="body.SALES_ORG == null || body.SALES_ORG.length() == 0 ? '-' : body.SALES_ORG" out="SALES_ORG" />
<pfx:body in="FLAG_TO_RELEVANT"/>
<pfx:body in="FLAG_QTY_RELEVANT" />
<pfx:body in="FLAG_IPT_RELEVANT"/>
<pfx:body in="FLAG_COGS_RELEVANT"/>
</pfx:loadMapper>
Route:
<split streaming="true" stopOnException="true">
<tokenize token="\n" group="5000"/>
<log loggingLevel="INFO" message="Going to unmarshall ${property[CamelSplitIndex]}. batch of ORDER REASONS from CVS file" logName="pig.orderReasonCsvLoad"/>
<to uri="pfx-csv:unmarshal?header={{orderReasonData-header}}&skipHeaderRecord=false&quoteDisabled=true&delimiter=;"/>
<log loggingLevel="INFO" message="Unmarshalled ${property[CamelSplitIndex]}. batch of ORDER REASONS from CVS file successfuly" logName="pig.orderReasonCsvLoad"/>
<log loggingLevel="INFO" message="Going to load ${property[CamelSplitIndex]}. batch of ORDER REASONS to DB" logName="pig.orderReasonCsvLoad"/>
<to uri="pfx-sql:insert?mapper=orderReasonMapper&businessKeys=ORDER_REASON,SALES_ORG&table=ORDER_REASON&dialect=POSTGRESQL"/>
<log loggingLevel="INFO" message="ORDER REASON data ${property[CamelSplitIndex]}. batch load to DB processed successfully" logName="pig.billingTransactionsCsvLoad"/>
</split>
Â
IntegrationManager version 5.8.0