Sometimes, it's more convenient to call a sequence of SQL statements from within Talend Open Studio instead of through a command line tool like sqlplus. In a previous post, I wrote about using the tFileInputDelimited component to drive the processing. This post suggests using the tFixedFlowInput component with the statements embedded in the Component View.
This job uses an open/process/commit/close pattern on a datasource defined in the Metadata panel. tFixedFlowInput defines a list and uses each iteration to produce a flow record. Each flow record is a valid DDL String -- in this case a DELETE -- which is executed by a tMysqlRow. Once the flow is finished, the results are committed and the connection closed.
|Job with tFixedFlowInput|
The list of SQL statements can be defined using a structured editor (Inline Table) or as a block of text (Inline Content). In the Inline Table, each UI row renders an element. In this example, there is only a single field containing the SQL statement, but there could be more than one field.
|Inline Table Config of tFixedFlowInput|
|Inline Content Config of tFixedFlowInput|
To execute the SQL, output the sqlStatement field of row1. The tFixedFlowInput schema defines a single "sqlStatement" field that is of type String.
|tMysqlRow Executing Statement from row1|