The RDB(Get) component outputs the results of the specified RDBMS SELECT statement.
To retrieve the fields of RDB in the flow service, it is necessary to make the type of the field of each RDB correspond to the data type of the flow service. About the field of each RDB and correspondence with the data type of the flow service, please refer to "Conversion of data type with RDB" of flow service manual.
| Input | Format | All |
|---|---|---|
| Number of Inputs | Unlimited | |
| Description |
The input stream is not used. Stream formats are not selectable. |
|
| Output | Format | Record |
| Name | Data Type | Mapping | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Connection | connection | - | Specifies RDB to connect. The connections are defined in the Connection Pane of Flow Designer or the Flow Service Management Console. | ||||||
| SQL | string | In & Out |
Specifies the SQL to be called against RDBMS. The SQLBuilder will automatically create the SQL statement that will be set for this property. It is possible to modify the SQL statement after it is generated. For details, please refer to following topic "Using SQL Builder". The SQL statement can be set with a Mapper component. |
||||||
| RecordFilter | boolean | - |
Specifies whether the StartRow and GetCount properties are to be used to filter out a subset of records from the SELECT operations resulting record set.
|
||||||
| StartRow | int | In & Out |
If RecordFilter =true, this property specifies from which record in the SELECT operation's resulting record set records are to be filtered to the output. The index of the line is an index of one base. If the StartRow is greater than the number of records in the SELECT operation's resulting record set, a RecordNotFoundException will occur. If the CountZeroException is set to false an empty set is output. |
||||||
| GetCount | int | In & Out |
If RecordFilter =true, this property specifies how many records in the SELECT operation's resulting record set records are to be filtered to the output. For example, if StartRow =11 and GetCount =10, the ten records starting from the SELECT operation's resulting record set's eleventh row will be output. If GetCount is greater than the number of records located from the StartRow , all the records from the StartRow to the end of the record set will be output. If GetCount is set to zero, all records from the StartRow to the end of the record set will be output. |
||||||
| QueryTimeout | int | In & Out |
Specifies the time, in seconds, that this component will wait for the SELECT command results to be returned by the RDBMS. If a result is not received by the specified QueryTimeout period, Exception is thrown. If this property is set to zero, this component will not timeout. |
||||||
| LoopProcess | loopProcess | - |
Specifies if it outputs results as a stream by specified lines by GetByLoop or as a single stream.
|
||||||
| GetByLoop | int | In & Out | Specifies the number of lines to output at once if LoopProcess is set to true. | ||||||
| CountZeroException | boolean | - |
Specifies whether to throw error when the number of results are empty.
|
||||||
| Transaction | boolean | - |
Specifies whether to treat the connection to DBMS as a transaction. If the process of this component doesn't update anything and the flow is not transactional, it is faster when this property is set to false. Typically, because this component calls only SELECT statement, this property don't require to be set to true.
|
||||||
| FetchSize | int | - |
Specifies the size to set JDBC setFetchSize() Default value is 1000. In the case of using MySQL, Specifies "useCursorFetch = true" URL for the connection. |
||||||
| TransformSQLParameter | boolean | - |
If false , component do not transform sql parameter like $ and ? in sql statement.
In this case, note that the SQL Parameter will be ignored.
|
||||||
| SQLParameter | category | In & Out | Defines the name, data type and default value of the parameters that may be used in an SQL statement. SQLParameter is defined in the SQLBuilder. Please refer to following topic "Using SQL Builder". |
If LoopProcess =true, each record resulting from the SQL query will be sent out as an individual record set. This results in looping.
| Commit | If Transaction =true, commits the RDBMS. |
|---|---|
| Rollback | If Transaction =true, rolls back the RDBMS. |
| Type | Parameter | Stream for error handling flow | Error Code | Description |
|---|---|---|---|---|
| Exception | None | This component's input stream | Database vendor-specific exception code | Invalid SQL . |
| - | Connection not found. | |||
| Database vendor-specific exception code | The query times out. | |||
| ConnectException | None | This component's input stream | - | Failure connecting to the DBMS. |
| RecordNotFoundException | None | This component's input stream | 3 | CountZeroException is set to true, and the query results in zero records. |
| 4 | CountZeroException is set to true, and the record filtering results in zero records. |
When using Microsoft Access in database, the combination of setting「Transactionize」property of start component in property flow to「No」, setting the LoopProcess property of this component to「true」, and setting Transaction property to「true」can not be used.
When flow is canceled, the flow usually aborts after the execution of that component is ends. However, the execution of this component is forced to be ended, then it aborts. If the execution is forced to be ended, the transaction is rolled back.
After the SQL builder is finished, the「Do you want to update field definition?」message dialog box will be shown. When click「Yes」, the columns of SELECT statement selected by SQL builder are defined in stream pane as output stream. When click「No」, they will not be defined in stream pane.
To retrieve records as the output stream of this component, though it is required to define fields in stream pane, since each column of SELECT statement generated by SQL builder and the fields of output stream are mapped by the order, it is not necessary that column name and field name must match.
Even when the number of SELECTed columns is different from the number of fields defined in the output stream, or when the column data type is different from the data type of corresponding field, the mapping can also be implemented by the order.
SQLParameter defined values and character strings can be inserted dynamically into the SQL statement. SQL statement parameters are referenced in the following two ways:
A replacement string replaces the parameter reference in the SQL statement.
The replacement string replaces the parameter reference before the SQL query is made.
The replacement string's SQLParameter data type must be set to String.
Use the appropriate escape sequence "$$" or "??" to have a single "$" or "?" character in the resulting query statement.
An SQLParameter defined parameter value can be inserted into the SQL statement.
The SQL parameter's value replaces the SQL parameter reference before the SQL query is made.
For example, given the SQL statement below:
SELECT GROUP, NAME, KANA FROM EMPLOYEE WHERE GROUP = ?GROUP? ORDER BY $ORDER$
and the SQL parameters defined as:
GROUP=Sales
ORDER=KANA
the resulting query statement will be:
SELECT GROUP, NAME, KANA FROM EMPLOYEE WHERE GROUP = ? ORDER BY KANA
where the GROUP parameter's "Sales" value will be assigned to the first ? position.
If setting the SQL property with a preceding Mapper component, or using replacement string substitution within the SQL statement, a statement construction pass will be required before the SQL statement is executed.
Using only an SQLParameter value reference runs faster than a replacement string reference.
SQL builder is a specialized tool to automatically generate SQL statement. Using SQL builder, the following items can be done through simple operations.
Start SQL builder using any of the following operations.
_1.png)
After starting the SQL builder, the table list will be shown in (1). To specify the tables to read, there are two ways. Using the following operations, fields list of the table will be shown in (2).
Click the table name from list of (1) and start to drag, and drop to (2).
Right-click the empty space of (2) and click the「Specify table names and add」from the shown menu. Input table names in the shown dialog and then click「OK」.
Click the table shown in (1) or (2), the detailed information will be shown in (3).
To specify the field to actually read, there are two ways. Following the operations below, the SQL statement will be shown in (5).
Select the checkbox which is on the left side of field name in the list of fields. It will be shown in the select column tab of (4). To cancel the specified fields, clear the checkbox. It will be deleted from the select column tab of (4).
Click the empty field of field name, and select fields to read from the shown pull-down list.
Click field in (4), right-click and then execute「Move up」「Move down」「Delete」from the shown menu.
Right-click in page (2) and when execute「Inhibit duplicates(DISTINCT)」from the shown menu, DISTINCT statement will be attached to the auto-generated SELECT statement.
To sort the records in ascending or descending order and then read, there are two following ways. Using the following operations, it will reflected in the SQL statement of (5).
Click a field in the field list, right-click and then click「Ascending」or「Descending」from「Add to sort」of the shown menu.
Click the empty field of field name, and select the sort key field from the shown pull-down list. Select「Ascending」or「Descending」from the sort order pull-down list of the specified field name.
Click a field in the field list, right-click and then click「(none)」from「Add to sort」of the shown menu.
Or click a field of the sort tab, right-click and then click the「Delete」from the shown menu.
To apply the aggregate functions on the field, there are the following two ways. Following the operations below, the SQL statement will be shown in (5).
Click a field in the field list, right-click and then select aggregate functions which to apply through「Aggregate functions」from the shown menu.
Click the empty field of field name, and then select fields which apply aggregate functions from the shown pull-down list. Select aggregate functions which to apply from the aggregate function pull-down list of the specified field name.
When setting「COUNT(*)」, it can only be set from page「2」, the selection can not be implemented in the aggregate function tab.
Select fields in page (2), right-click and then select「none」through「Aggregate functions」from the shown menu.
Or click the fields of aggregate function tab, right-click and then click「Delete」from the shown menu.
When aggregate functions are set but the field is not contained in SELECT object(Field is not checked), that item will not be contained in SELECT statement.
Fields which do not contain the aggregate functions in the field of SELECT object will be set automatically to the GROUP BY statement.
In SQL builder, the SQL statement which contains relations can be generated automatically. To set relations among tables, please follow the steps below.
To delete relations, right-click the combined link and then click「Delete relations」from the shown menu.
In SQL builder, you can compare the extract conditions of record with a fixed value or a dynamic value in the Flow. Also, you can input the conditional expressions directly and add it to the SQL statement.
The extract conditions will be added to the SQL statement of (5). The conditional expressions will be shown in the field list of (2).
In SQL builder, define any names of the parameters, and through specifying the parameter names when adding conditions to field name as extract conditions, parameters can be embedded to the WHERE statement of SQL statement. Config the mapper before this component, and through mapping to the defined parameters, you can set the dynamic values in execution as extract conditions.
To specify the extract conditions of dynamic values, please follow the steps below.
Config the mapper before RDBGet component, and mapper value fields to the field names of parameters which exist on the output side of mapping window.
Extract conditions will be added to the SQL statement of (5). The conditional expressions will be shown in the field list of (2).
To specify any conditions, there are the following two ways. By the following operations, the extract conditions will be added to the SQL statement of (5).
From edit dialog box of conditions
From page (4)(Condition tab)
When combining various conditions to extract, you can specify the logical operators in the conditional tab of (4). Click the「AND」or「OR」from the pull-down list of「Relationships」item of conditional field.
To edit the extracted conditions, double-click the field of conditional tab. Or, click the field, right-click and click「Edit conditions」from the shown menu.
Click the field of conditional tab, right-click and click the「Delete」from the shown menu.
SQL parameters of SQL builder, except for setting the extract conditions(WHERE statement), can replace any strings of SQL statement. Define parameters of any name, and directly write parameters in (5). Besides, you can write when specifying any conditions in the edit dialog box of conditions. Config the mapper before this component, through mapping to the defined parameters, you can set dynamic SQL statement at runtime.
To specify dynamic SQL statement, follow the steps below.
Right-click a field in (4) and do「Move up」「Move down」「Insert」「Delete」from the shown menu.
The auto-generated SQL statement through the specifications of (1)~(4) will display in (5). When directly edit (5), that SQL statement will be issued to RDBMS directly. In direct edition, when synchronize the auto-generated SQL statement, please pay attention that it will return to the original statement. About synchronization settings, please refer to the following paragraph 「Options of displaying auto-generated SQL statement」.
To actually issue and test the SQL statement in RDBMS, perform the following steps.
When it is normally ended, the execution result set will display in the dialog box. If it is ended abnormally, the result set will display in the error message dialog box.
Change the lines of「Lines of test result」field on the bottom right side of page (5) and then click「Test SELECT」. Initial value is 100.
For displaying (5), you can specify the options on the bottom right side of page.
Use SQL builder to select specified fields, and the conditions are called model. If the「Always synchronize SQL」checkbox is ON, models of (1)~(4) will synchronize with the SQL statement of (5) and are auto-generated. The auto-generated SQL statement can also be directly edited in (5). In this case, to manipulate the model and do not synchronize to the directly edited SQL statement, the「Always synchronize SQL」checkbox will automatically be OFF. When reset the direct editing or auto-generate SQL statement from re-operated model, click「Apply model to SQL」.
When SQL value is as follows
SELECT GROUP, NAME, KANA FROM EMPLOYEE WHERE GROUP = ?GROUP? ORDER BY $ORDER$
When SQLParameter is as follows
GROUP=Sales
ORDER=KANA
The actually executed SQL statement is as follows. 「Sales」will be input in the GROUP parameter, and「KANA」will be input in the ORDER parameter.
SELECT GROUP, NAME, KANA FROM EMPLOYEE WHERE GROUP = Sales ORDER BY KANA