DB Looping

This node runs SQL queries in the connected database restricted by the possible values given by the input table. It restricts each SQL query so that only rows that match the possible values from the input table are retrieved whereas the number of values per query can be defined. This node is usually used to execute IN queries e.g. SELECT * FROM table WHERE Col1 IN ($Col1_values$) where #Col1_values# will be replaced by a comma separated list of values from the input table.

Options

Settings

SQL Statement
Enter the SQL-like query here, for example SELECT * FROM table WHERE Col1 IN ($Col1_values$). If the table place holder isn't changed, then it will be replaced with the query from the database input port. Constant values and any identifier from the database column list, column list and flow variable list can be used in the SQL statement by double clicking the column or variable name. For each column place holder a list of values from the input column is send to the database whereas the size of the list is defined by the No of values per query parameter.
To open code completion press <CTRL> + <SPACE>. Table and columns names are only suggested if the metadata is available e.g. shown in the Database Metadata Browser. To perform undo press <CTRL> + Z and for re-do <CTRL> + Y.
Database Metadata Browser
The Database Metadata Browser allows you to browse the database metadata and to select a table or view. Click the Refresh button at the bottom right to re-fetch the metadata from the database. The data is grouped by database schema and type e.g. view or table. By clicking on an entity it shows contained elements. If you click on a table or view the dialog will fetch the column names and types of the selected element. To select a table or view select the name and click OK or double click the element. To search for a particular table or view enter the name or parts of the name into the search field and click on the Magnifying Glass button or press enter.
Database Column List
The list contains the columns that are available in the input DB Data object. Double clicking any of the entries will insert the respective identifier at the current cursor position (replacing the selection, if any).
Column List
The list contains the columns that are available in the KNIME input table. Double clicking any of the entries will insert the respective identifier at the current cursor position (replacing the selection, if any). The identifier will be replaced during execution with a comma separated list of values from this column.
Flow Variable List
The list contains the flow variables that are currently available at the node input. Double clicking any of the entries will insert the respective identifier at the current cursor position (replacing the selection, if any).
No of values per query
Specifies the number of values send with each SQL query e.g. 3 will result in using the values of 3 rows from the input KNIME data table within each query send to the database for execution. The last query will us NULL for any missing values in the last query e.g. the last query for a table with 5 rows and 2 values per query will have the last value from the table and one NULL in the last query send to the database.
Read all
Execute a single query with all values of the selected columns from the input table.
Aggregate by row
If checked, then the final output table will only contain one row per query. If the query returns multiple results each column values are aggregated into a collection.
Append input columns
If checked, then the columns from the input table will be appended to the output table. Only columns that are used in the looping SQL statement will be appended.
Include empty results
If checked, then all empty results will be appended to the output table and represented as Missing Cell. All input rows will be retained.
Retain all columns
If checked, then all columns including columns that are not used in the looping SQL statement will be appended to the output table.
Fail on error
If checked, then the node will fail if there is any error. Otherwise, the node will continue executing and all errors will be collected in the second output table.

Input Type Mapping

This tab allows you to define rules to map from database types to KNIME types.

Mapping by Name
Columns that match the given name (or regular expression) and database type will be mapped to the specified KNIME type.
Mapping by Type
Columns that match the given database type will be mapped to the specified KNIME type.

Output Type Mapping

This tab allows you to define rules to map from KNIME types to database types.

Mapping by Name
Columns that match the given name (or regular expression) and KNIME type will be mapped to the specified database type.
Mapping by Type
Columns that match the given KNIME type will be mapped to the specified database type.

Input Ports

Icon
KNIME data table with possible values used to constrain the database SQL query.
Icon
DB Data that will be used during query execution.

Output Ports

Icon
KNIME data table with the result from the database and optionally the data columns from the input table.
Icon
Table with error message if any, otherwise empty table.

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.