DBExecute

We assume that you have already learned what is described in:

If you want to find the right Other component for your purposes, see Others Comparison.

Short Summary

DBExecute executes SQL/DML/DDL statements against a database.

Component Same input metadata Sorted inputs Inputs Outputs Each to all outputs[ 1)] Java CTL
DBExecute-
no
0-10-2-
no
no

[ 1)] Component sends each data record to all connected output ports.

Abstract

DBExecute executes specified SQL/DML/DDL statements against a database connected using the JDBC driver. It can execute queries, transactions, call stored procedures, or functions. Input parameters can be received through the single input port and output parameters or result set are sent to the first output port. Error information can be sent to the second output port.

Icon

Ports

Port typeNumberRequiredDescriptionMetadata
Input0[ 1)]Input records for stored procedure or the whole SQL commandsany
Output0[ 2)]Output parameters of stored procedure or result set of the queryany
1
no
for error informationbased on input metadata [ 3)]

[ 1)] Input port must be connected if Query input parameters attribute is specified or if the whole SQL query is received through input port.

[ 2)] Output port must be connected if the Query output parameters or Return set output fields attribute is required.

[ 3)] Metadata on output port 1 may contain any number of fields from input (same names and types) along with up to two additional fields for error information. Input metadata are mapped automatically according to their name(s) and type(s). The two error fields may have any names and must be set to the following Autofilling Functions: ErrCode and ErrText

DBExecute Attributes

AttributeReqDescriptionPossible values
Basic
DB connectionyesID of the DB connection to be used. 
Query URL1)One of these two options: Either the name of external file, including path, defining SQL query with the same characteristics as described in the SQL query attribute, or the File URL attribute string that is used for port reading. See SQL Query Received from Input Port for details.  
SQL query1)SQL query defined in the graph. Contains SQL/DML/DDL statement(s) that should be executed against database. If stored procedure or function with parameters should be called or if output data set should be produced, the form of the statement must be the folowing: {[? = ]call procedureName([?[,?,[...]])}. (Do not forget enclose the statement in curly brackets!) At the same time, if the input and/or the output parameters are required, corresponding attributes are to be defined for them (Query input parameters, Query output parameters and/or Result set output fields, respectively). In addition, if the query consists of multiple statements, they must be separated from each other by specified SQL statement delimiter. Statements will be executed one by one. 
SQL statement delimiter Delimiter between individual SQL statements in the SQL query or Query URL attribute. Default delimiter is semicolon.";" (default) | other character
Print statements By default, SQL commands are not printed. If set to true, they are sent to stdout.false (default) | true
Transaction set Specifies whether the statements should be executed in transaction. See Transaction Set for more information. Is applied only if database supports transactions.SET (default) | ONE | ALL | NEVER_COMMIT
Advanced
Query source charset Encoding of external file specified in the Query URL attribute.ISO-8859-1 (default) | <other encodings>
Call as stored procedure By default, SQL commands are not executed as stored procedure calls unless this attribute is switched to true. If they are called as stored procedures, JDBC CallableStatement is used.false (default) | true
Query input parameters Used when stored procedure/function with input parameters is called. It is a sequence of the following type: 1:=$inputField1;...;n:=$inputFieldN. Value of each specified input field is mapped to coresponding parameter (whose position in SQL query equals to the specified number). This attribute cannot be specified if SQL commands should be received through input port. 
Query output parameters Used when stored procedure/function with output parameters or return value is called. It is a equence of the following type: 1:=$outputField1;...;n:=$outputFieldN. Value of each output parameter (whose position in SQL query equals to the specified number) is mapped to the specified field. If the function returns a value, this value is represented by the first parameter. 
Result set output fields If stored procedure or function returns a set of data, its output will be mapped to given output fields. Attribute is expressed as a sequence of output field names separated from each other by semicolon. 
Error actions Definition of the action that should be performed when the specified query throws an SQL Exception. See Return Values of Transformations. 
Error log URL of the file to which error messages for specified Error actions should be written. If not set, they are written to Console. 

Legend:

1): One of these must be set. If both are specified, Query URL has higher priority.

Advanced Description

SQL Query Received from Input Port

SQL query can also be received from input port.

In this case, two values of the Query URL attribute are allowed:

For more details about reading data from input port see Input Port Reading.

Transaction Set

Options are the following:

Tips & Tricks

Specific Cases