Available in Community Designer

Short Description
DBExecute Attributes
Best Practices
See also

Short Description

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.

Component Same input metadata Sorted inputs Inputs Outputs Each to all outputs Java CTL Auto-propagated metadata


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
for error informationbased on input metadata

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

[ 2] The output port must be connected if the Query output parameters or Return set output fields attribute is specified.


DBExecute does not propagate metadata.

DBExecute has no metadata template.

Metadata on output port 1 may contain any number of fields from input (same names and types). Input metadata are mapped automatically according to their name(s) and type(s).

Output metadata may contain additional fields for error information. The two error fields may have any names and must be set to the following Autofilling Functions: ErrCode and ErrText

DBExecute Attributes

AttributeReqDescriptionPossible values
DB connectionyesID of the DB connection to be used. 
SQL query [1]

SQL query defined in the graph. Contains SQL/DML/DDL statement(s) that should be executed against database. If a 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 following: {[? = ]call procedureName([?[,?,[...]])}. (Do not forget to 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).

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.

Query URL [1] One of these two options: Either the name of an 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.  
Query source charset Encoding of external file specified in the Query URL attribute. E.g. UTF-8 | <other encodings>
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
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. See Calling Stored Procedures and Functions.false (default) | true
Query input parameters  Used when a stored procedure/function with input parameters is called. It is a sequence of the following type: 1:=$inputField1;...;n:=$inputFieldN. The value of each specified input field is mapped to the corresponding parameter (whose position in SQL query equals to the specified number). This attribute cannot be specified if SQL commands should be received through the input port.  
Query output parameters  Used when a stored procedure or function with output parameters or return value is called. It is a sequence of the following type: 1:=$outputField1;...;n:=$outputFieldN. Value of each output parameter (specified by its position in the SQL query) will be written to the specified field. If the function returns a value, this value is represented by the first parameter. Use "result_set" to denote output parameters that return data sets, typically by returning a cursor - so, e.g. "2:=result_set". See Calling Stored Procedures and Functions.  
Result set output fields  If a stored procedure or function returns a set of data, its output will be mapped to given output fields. The attribute is expressed as a sequence of output field names separated from each other by semicolon. See Calling Stored Procedures and Functions.  
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.  

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


SQL Query Received from Input Port
Transaction Set
Calling Stored Procedures and Functions

SQL Query Received from Input Port

SQL query can also be received from the input port.

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

  • SQL command is sent through the input edge.

    The attribute value is: port:$0.fieldName:discrete.

    Metadata of this edge has neither default delimiter, nor record delimiter, but EOF as delimiter must be set to true.

  • The name of the file containing the SQL command, including path, is sent through the input edge.

    The attribute value is: port:$0.fieldName:source.

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

Transaction Set

Options are the following:

  • One statement

    Commit is performed after each query execution.

  • One set of statements

    All statements are executed for each input record. Commit is performed after a set of statements.

    For this reason, if an error occurs during the execution of any statement for any of the records, all statements are rolled back for such a record.

  • All statements

    Commit is performed after all statements, only.

    For this reason, if an error occurs, all operations are rolled back.

  • Never commit

    Commit or rollback may be called from other component in different phase. There is no automatic rollback.


    If no error occurs, the connection closure results in autocommit even if Never commit is selected. If you need to rollback, the rollback must be called before autocommit on session's termination.

    If you want to use the Never commit option and perform commit or rollback from another component in another phase, set Thread-safe connection in advanced Connection settings to false. Otherwise each component will have different connection and autocommit will be performed at the end of processing of particular components.

Calling Stored Procedures and Functions

The following table summarizes basic configuration examples to call stored procedures, setting input parameters and obtaining output values in the form of output parameters, return values or cursors.

SQL object DeclarationOutputSQL queryQuery input port parametersQuery output port parametersResult set output fields
PROCEDURE remove_customer(id IN NUMBER)None{ call remove_costumer(?) };1:=$customer_id;  
PROCEDURE find_customer_name_by_id(id IN NUMBER, name OUT VARCHAR)Parameter{ call find_customer_name_by_id(?, ?) };1:=$customer_id;2:=$customer_name; 
PROCEDURE get_newest_customer(c_cursor OUT SYS_REFCURSOR)Cursor{ call get_newest_customer(?) }; 1:=result_set;customer_id;custom_name;customer_address
PROCEDURE get_customer(id IN NUMBER, c_cursor OUT SYS_REFCURSOR)Cursor{ call get_customer(?, ?) };1:=$customer_id;2:=result_set;customer_id;custom_name;customer_address
FUNCTION get_customer_name_by_id(id IN NUMBER) RETURN VARCHARValue{ ? = call get_customer_name_by_id(?) };2:=$customer_id;1:=$customer_name; 


Creating a database table with DBExecute

This example show the basic use case of this component.

Create a database table rivers with two columns: name and length.


Create a database connection RiversConnection. See Creating Internal Database Connections.

Set DB Connection to RiversConnection connection.

Enter the CREATE statement into SQL Query attribute.

DB ConnectionRiversConnection
Query URL
  name VARCHAR(50) NOT NULL,
  length INTEGER

If you use one graph to create a database table and insert data to it, do no forget to put DBExecute to and the component inserting the data into different phases. DBExecute should be in lower phase and DBOutputTable (or other component writing to database) in higher phase.

Executing multiple queries

DBExecute is not limited to execution of one SQL query.

Create table rivers as in the previous example. If the table exists, drop it first.

DB ConnectionRiversConnection
Query URL
  name VARCHAR(50) NOT NULL,
  length INTEGER

Do not forget to end statements with semicolons.

Note: some databases (e.g. Oracle) does not understand the IF EXISTS part of the query. If you use a database that does not support IF EXISTS, change the first line of query to DROP TABLE rivers;.

Creating a stored procedure

Create a stored procedure that inserts data into table products. The table has been created with the following query:

CREATE TABLE products (
  product_name VARCHAR(40) NOT NULL

Create a database connection ProductConnection.

DB ConnectionProductConnection
Query URL
  INSERT INTO products (product_name) VALUES(param); 
' LANGUAGE plpgsql;

The example has been tested with Postgresql 9.2.

Best Practices

Upload and Download of Data

In general, you shouldn't use the DBExecute component for INSERT and SELECT statements. For uploading data to a database, please use the DBOutputTable component. Similarly, for downloading use the DBInputTable component.

Transferring data within a database

The best practice to load data from one table to another in the same database is to do it inside the database. You can use the DBExecute component with a query like this

insert into my_table select * from another_table

because pulling data out from the database and putting them in is slower as the data has to be parsed during the reading and formatted when writing.


If the query is specified in an external file (with Query URL), we recommend users to explicitly specify Query source charset.


Boolean and Oracle JDBC

Calling arguments or return values of the PL/SQL RECORD, BOOLEAN, or table with non-scalar elements are not supported by Oracle JDBC Drivers. See Oracle JDBC Reference

As a workaround, you can create a wrapper procedure. See Wrapper procedures

See also

Common Properties of Components
Specific Attribute Types
Others Comparison