Primeur Online Docs
Data Shaper
Data Shaper
  • 🚀GETTING STARTED
    • What is Primeur Data Shaper
      • What is the Data Shaper Designer
      • What is the Data Shaper Server
      • What is the Data Shaper Cluster
    • How does the Data Shaper Designer work
      • Designer Views and Graphs
      • Data Shaper Graphs
      • Designer Projects and Sandboxes
      • Data Shaper Designer Reference
    • How do the Data Shaper Server and Cluster work
      • Data Shaper Server and Cluster
      • Data Shaper Server Reference
    • VFS Graph Components
      • DataOneFileDescriptor (DOFD) metadata
      • Passing parameters from Data One Contract to Data Shaper graph
      • Inheriting Data One context attributes in Data Shaper graph
  • DATA SHAPER DESIGNER
    • Configuration
      • Runtime configuration
        • Logging
        • Master Password
        • User Classpath
      • Data Shaper Server Integration
      • Execution monitoring
      • Java configuration
      • Engine configuration
      • Refresh Operation
    • Designer User Interface
      • Graph Editor with Palette of Components
      • Project Explorer Pane
      • Outline Pane
      • Tabs Pane
      • Execution Tab
      • Keyboard Shortcuts
    • Projects
      • Creating Data Shaper projects
      • Converting Data Shaper projects
      • Structure of Data Shaper projects
      • Versioning of server project content
      • Working with Data Shaper Server Projects
      • Project configuration
    • Graphs
      • Creating an empty graph
      • Creating a simple graph
        • Placing Components
        • Placing Components from Palette
        • Connecting Components with Edges
    • Execution
      • Successful Graph Execution
      • Run configuration
      • Connecting to a running job
      • Graph states
    • Common dialogs
      • URL file dialog
      • Edit Value dialog
      • Open Type dialog
    • Import
      • Import Data Shaper projects
      • Import from Data Shaper server sandbox
      • Import graphs
      • Import metadata
    • Export
      • Export graphs to HTML
      • Export to Data Shaper Server sandbox
      • Export image
      • Export Project as Library
    • Graph tracking
      • Changing record count font size
    • Search functionality
    • Working with Data Shaper server
      • Data Shaper server project basic principles
      • Connecting via HTTP
      • Connecting via HTTPS
      • Connecting via Proxy Server
    • Graph components
      • Adding components
      • Finding components
      • Edit component dialog box
      • Enable/disable component
      • Passing data through disabled component
      • Common properties of components
      • Specific attribute types
      • Metadata templates
    • Edges
      • Connecting Components with Edges
      • Types of Edges
      • Assigning Metadata to Edges
      • Colors of Edges
      • Debugging Edges
      • Edge Memory Allocation
    • Metadata
      • Records and Fields
        • Record Types
        • Data Types in Metadata
        • Data Formats
        • Locale and Locale Sensitivity
        • Time Zone
        • Autofilling Functions
      • Metadata Types
        • Internal Metadata
        • External (Shared) Metadata
        • SQL Query Metadata
        • Reading Metadata from Special Sources
      • Auto-propagated Metadata
        • Sources of Auto-Propagated Metadata
        • Explicitly Propagated Metadata
        • Priorities of Metadata
        • Propagation of SQL Query Metadata
      • Creating Metadata
        • Extracting Metadata from a Flat File
        • Extracting Metadata from an XLS(X) File
        • Extracting Metadata from a Database
        • Extracting Metadata from a DBase File
        • Extracting Metadata from Salesforce
        • SQL Query Metadata
        • User Defined Metadata
      • Merging Existing Metadata
      • Creating Database Table from Metadata and Database Connection
      • Metadata Editor
        • Opening Metadata Editor
        • Basics of Metadata Editor
        • Record Pane
        • Field Name vs. Label vs. Description
        • Details Pane
      • Changing and Defining Delimiters
      • Editing Metadata in the Source Code
      • Multi-value Fields
        • Lists and Maps Support in Components
        • Joining on multivalue fields (Comparison Rules)
    • Connections
      • Database Connections
        • Internal Database Connections
        • External (Shared) Database Connections
        • Database Connections Properties
        • Encryption of Access Password
        • Browsing Database and Extracting Metadata from Database Tables
        • Windows Authentication on Microsoft SQL Server
        • Snowflake Connection
        • Hive Connection
        • Troubleshooting
      • JMS Connections
      • QuickBase Connections
      • Hadoop Connections
      • Kafka Connections
      • OAuth2 Connections
      • MongoDB Connections
      • Salesforce Connections
    • Lookup Tables
      • Lookup Tables in Cluster Environment
      • Internal Lookup Tables
      • External (Shared) Lookup Tables
      • Types of Lookup Tables
    • Sequences
      • Persistent Sequences
      • Non Persistent Sequences
      • Internal Sequences
      • External (Shared) Sequences
      • Editing a Sequence
      • Sequences in Cluster Environment
    • Parameters
      • Internal Parameters
      • External (Shared) Parameters
      • Secure Graph Parameters
      • Graph Parameter Editor
      • Secure Graph Parameters
      • Parameters with CTL2 Expressions (Dynamic Parameters)
      • Environment Variables
      • Canonicalizing File Paths
      • Using Parameters
    • Internal/External Graph Elements
    • Dictionary
      • Creating a Dictionary
      • Using a Dictionary in Graphs
    • Execution Properties
    • Notes in Graphs
      • Placing Notes into Graph
      • Resizing Notes
      • Editing Notes
      • Formatted Text
      • Links from Notes
      • Folding Notes
      • Notes Properties
    • Transformations
      • Defining Transformations
      • Transform Editor
      • Common Java Interfaces
    • Data Partitioning (Parallel Running)
    • Data Partitioning in Cluster
      • High Availability
      • Scalability
      • Graph Allocation Examples
      • Example of Distributed Execution
      • Remote Edges
    • Readers
      • Common Properties of Readers
      • ComplexDataReader
      • DatabaseReader
      • DataGenerator
      • DataOneVFSReader
      • EDIFACTReader
      • FlatFileReader
      • JSONExtract
      • JSONReader
      • LDAPReader
      • MultiLevelReader
      • SpreadsheetDataReader
      • UniversalDataReader
      • X12Reader
      • XMLExtract
      • XMLReader
      • XMLXPathReader
    • Writers
      • Common Properties of Writers
      • DatabaseWriter
      • DataOneVFSWriter
      • EDIFACTWriter
      • FlatFileWriter
      • JSONWriter
      • LDAPWriter
      • SpreadsheetDataWriter
      • HIDDEN StructuredDataWriter
      • HIDDEN TableauWriter
      • Trash
      • UniversalDataWriter
      • X12Writer
      • XMLWriter
    • Transformers
      • Common Properties of Transformers
      • Aggregate
      • Concatenate
      • DataIntersection
      • DataSampler
      • Dedup
      • Denormalizer
      • ExtSort
      • FastSort
      • Filter
      • Map
      • Merge
      • MetaPivot
      • Normalizer
      • Partition
      • Pivot
      • Rollup
      • SimpleCopy
      • SimpleGather
      • SortWithinGroups
      • XSLTransformer
    • Joiners
      • Common Properties of Joiners
      • Combine
      • CrossJoin
      • DBJoin
      • ExtHashJoin
      • ExtMergeJoin
      • LookupJoin
      • RelationalJoin
    • Others
      • Common Properties of Others
      • CheckForeignKey
      • DBExecute
      • HTTPConnector
      • LookupTableReaderWriter
      • WebServiceClient
    • CTL2 - Data Shaper Transformation Language
    • Language Reference
      • Program Structure
      • Comments
      • Import
      • Data Types in CTL2
      • Literals
      • Variables
      • Dictionary in CTL2
      • Operators
      • Simple Statement and Block of Statements
      • Control Statements
      • Error Handling
      • Functions
      • Conditional Fail Expression
      • Accessing Data Records and Fields
      • Mapping
      • Parameters
      • Regular Expressions
    • CTL Debugging
      • Debug Perspective
      • Importing and Exporting Breakpoints
      • Inspecting Variables and Expressions
      • Examples
    • Functions Reference
      • Conversion Functions
      • Date Functions
      • Mathematical Functions
      • String Functions
      • Mapping Functions
      • Container Functions
      • Record Functions (Dynamic Field Access)
      • Miscellaneous Functions
      • Lookup Table Functions
      • Sequence Functions
      • Data Service HTTP Library Functions
      • Custom CTL Functions
      • CTL2 Appendix - List of National-specific Characters
      • HIDDEN Subgraph Functions
    • Tutorial
      • Creating a Transformation Graph
      • Filtering the records
      • Sorting the Records
      • Processing Speed-up with Parallelization
      • Debugging the Java Transformation
  • DATA SHAPER SERVER
    • Introduction
    • Administration
      • Monitoring
    • Using Graphs
      • Job Queue
      • Execution History
      • Job Inspector
    • Cluster
      • Sandboxes in Cluster
      • Troubleshooting
  • Install Data Shaper
    • Install Data Shaper
      • Introduction to Data Shaper installation process
      • Planning Data Shaper installation
      • Data Shaper System Requirements
      • Data Shaper Domain Master Configuration reference
      • Performing Data Shaper initial installation and master configuration
        • Creating database objects for PostgreSQL
        • Creating database objects for Oracle
        • Executing Data Shaper installer
        • Configuring additional firewall rules for Data Shaper
Powered by GitBook
On this page
  • Short Description
  • Ports
  • Metadata
  • DBExecute Attributes
  • Details
  • SQL Query Received from Input Port
  • Transaction Set
  • Calling Stored Procedures and Functions
  • Examples
  • Creating a database table with DBExecute
  • Executing multiple queries
  • Creating a stored procedure
  • Getting errors
  • Best Practices
  • Troubleshooting
  • See also
  1. DATA SHAPER DESIGNER
  2. Others

DBExecute

PreviousCheckForeignKeyNextHTTPConnector

Last updated 1 month ago

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.

Hint! For executing INSERT/DELETE/UPDATE SQL queries operating on single records read from input port of the component, consider using instead, as it is optimized for these types of queries.

COMPONENT
SAME INPUT METADATA
SORTED INPUTS
INPUTS
OUTPUTS
EACH TO ALL OUTPUTS
JAVA
CTL
AUTO-PROPAGATED METADATA

DBExecute

-

x

0-1

0-2

-

x

x

x

Ports

PORT TYPE
NUMBER
REQUIRED
DESCRIPTION
METADATA

Input

0

[1]

Input records for stored procedure or the whole SQL commands.

Any

Output

0

[2]

Update count and the executed statement. Output parameters and result set of stored procedures.

Any

1

x

For error information

Based 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 the Return set output fields attribute is specified.

Metadata

DBExecute propagates input metadata to the first output port if not calling a stored procedure. It adds two output fields: updateCount and statement.

DBExecute has no metadata template.

Metadata on both output ports 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).

Standard output metadata may contain two additional fields: updateCount and statement (case insensitive, so UpdateCount or UPDATE_COUNT also works). If present, these fields are populated with the number of updated rows and the executed statement, respectively. This feature only works if the Call as stored procedure attribute is set to false.

DBExecute Attributes

ATTRIBUTE
REQ
DESCRIPTION
POSSIBLE VALUES

Basic

DB connection

yes

ID of the DB connection to be used.

SQL query

[1]

An 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 the 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. For details, see SQL Query Received from Input Port below.

Query source charset

Encoding of external file specified in the Query URL attribute.

E.g. UTF-8 | <other encodings>

SQL statement delimiter

A delimiter between individual SQL statements in the SQL query or Query URL attribute. Default delimiter is a 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. For more information, see Transaction Set below. Is applied only if the database supports transactions.

SET (default) | ONE | ALL | NEVER_COMMIT

Advanced

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 below.

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, for example "2:=result_set". See Calling Stored Procedures and Functions below.

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 a semicolon. See Calling Stored Procedures and Functions below.

Deprecated

Error actions

Error log

The 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.

Details

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 the path, is sent through the input edge. The attribute value is: port:$0.fieldName:source.

Transaction Set

Options are the following:

  • One statement The commit is performed after each query execution.

  • One set of statements All statements are executed for each input record. The 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 The commit is performed after all statements, only. For this reason, if an error occurs, all operations are rolled back.

  • Never commit The commit or rollback may be called from other component in a different phase. There is no automatic rollback.

Warning! 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 DECLARATION
OUTPUT
SQL QUERY
QUERY INPUT PORT PARAMETERS
QUERY OUTPUT PORT PARAMETERS
RESULT SET OUTPUT FIELDS

PROCEDURE remove_customer(id IN NUMBER)

None

{ call remove_customer(?) };

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 VARCHAR

Value

{ ? = call get_customer_name_by_id(?) };

2:=$customer_id;

1:=$customer_name;

Examples

Creating a database table with DBExecute

This example shows a basic use case of this component.

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

Solution

Set the DB Connection to RiversConnection connection.

Enter the CREATE statement into the SQL Query attribute.

  1. ATTRIBUTE DB Connection VALUE RiversConnection

  2. ATTRIBUTE Query URL VALUE

CREATE TABLE rivers (
    name VARCHAR(50) NOT NULL,
    length INTEGER
);

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.

Solution

  1. ATTRIBUTE DB Connection VALUE RiversConnection

  2. ATTRIBUTE Query URL VALUE

DROP TABLE IF EXISTS rivers;
CREATE TABLE rivers (
    name VARCHAR(50) NOT NULL,
    length INTEGER
);

Do not forget to end statements with semicolons.

Note: some databases (e.g. Oracle) do 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 the query to DROP TABLE rivers;.

Creating a stored procedure

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

CREATE TABLE products (
    product_name VARCHAR(40) NOT NULL
);

Solution

Create a database connection ProductConnection.

  1. ATTRIBUTE DB Connection VALUE ProductConnection

  2. ATTRIBUTE Query URL VALUE

CREATE OR REPLACE FUNCTION add_product(param VARCHAR(40))
RETURNS VOID AS '
BEGIN
    INSERT INTO products (product_name) VALUES(param);
END;
' LANGUAGE plpgsql;

The example has been tested with PostgreSQL 9.2 and 14.4.

Getting errors

This example shows a way to get errors related to an SQL query from the DBExecute component to send it to the next component for further processing.

The graph uses DBExecute to create a database table bricks. The bricks table contains details on products from our supplier. The table might exist or we could not have permission to create a table and we would like to receive the errors from the database.

Solution

Create a database connection ProductConnection.

  1. ATTRIBUTE DB Connection VALUE ProductConnection

  2. ATTRIBUTE Query URL VALUE

CREATE TABLE bricks (
    id INTEGER PRIMARY KEY NOT NULL,
    length integer,
    width integer,
    height integer,
    weight integer
);

Connect an edge to the second output port of DBExecute.

Assign metadata to the edge. The metadata should contain a String field that has Autofilling set to ErrCode.

Best Practices

Upload and Download of Data

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.

Charset

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

Troubleshooting

Boolean and Oracle JDBC

See also

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

The definition of an action that should be performed when the specified query throws an SQL Exception. See .

For more details about reading data from input port, see

Create a database connection RiversConnection. See .

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

Do not use the DBExecute component for INSERT and SELECT statements. For uploading data to a database, please use the component. Similarly, for downloading use the component.

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 .

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

DatabaseWriter
Autofilling Functions
Input Port Reading.
Creating Internal Database Connections
DatabaseWriter
DatabaseWriter
DatabaseReader
Oracle JDBC Reference
Wrapper procedures
DatabaseReader
DatabaseWriter
Common properties of components
Specific attribute types
Return Values of Transformations