Search

Home

Home

INPUT SQL

INPUT SQL

The INPUT SQL operator allows you to retrieve data from external sources—primarily SQL databases (e.g., PostgreSQL, MS SQL Server, Oracle, MySQL, SQLite, as well as databases using ODBC or OleDb drivers) and Excel files—and transform them into a data stream that is placed on the operator’s output data bus.

Data is retrieved using the SQL query defined in the operator’s configuration. This query can use:

The output of the operator is a data bus containing records that correspond to the query result. The columns of this data bus are automatically matched to the structure of the data returned by the source.

The INPUT SQL operator is most commonly used as the first step in integration processes, where source data is retrieved from external databases or spreadsheets and then further processed within the GRAVITY application.

Example of a GRAVITY project using the INPUT SQL operator:

image

SELECTING AND CREATING A DATABASE CONNECTION

Go to the Physical link tab in the operator’s properties.

image

If you already have a connection defined, select it from the Connection dropdown. The connection fields will be populated according to the selected connection.

image

You can modify the connection details by clicking the Edit button.

icon
Note that if the connection is already used by another operator, that operator will also use the modified connection.

If you do not yet have an appropriate database connection defined, you can create one using the Add button.

image

After entering the new connection details, you can test it using the Test connection button and save it in the system using the Save button.

image

Once saved, the connection will be available in the system under the name provided in the Name field.

icon
For more information on creating database connections, see New SQL Database Connection.

CREATING A DATABASE QUERY

Go to the Statement tab to create the database query. The database query is written in SQL.

image

In the SQL query, you can use parameters defined in the Parameters tab. You can select a parameter using the parameter dictionary.

image

You can also use the metalanguage in SQL queries to append parts of the query conditionally, depending on whether a condition is met.

  • Conditional expression syntax: {[expression] ? “expression true” : “expression false”}
  • Example usage in SQL code:

    select id, name from g.customer where {@id != null && @id != 0 ? " where and id = @id" : ""}

  • Expression that adds text wrapped in quotes:{TO_SQLTEXT([text to insert])}
  • Example usage in a query:

    select id, name, {TO_SQLTEXT(@email)} as email from g.customer

  • Expression that inserts text without any modification:{TO_PURE_VALUE([text to insert])}

Example usage in a query:

select id, name from {TO_PURE_VALUE(@schema)}.customer

CONFIGURING OPERATOR PARAMETERS

You can declare any number of parameters that can be used in the SQL query. The created parameters become project parameters, which means they can also be used by any operator within the project.

image

INCREMENTAL DATA DOWNLOAD

Data can be retrieved incrementally: to enable this, go to the Incremental download tab and set the Incremental downloading parameter to With incremental action.

image

If you choose the incremental method, you must specify the key position column (incremental column). Additionally, you can specify conditions that must be met for the system to treat the column’s value as the last retrieved value once the processing is complete. The last retrieved value can be cleared using the CLEAR VALUE option.

image
icon
The declaration of the incremental method is not visible in the STATEMENT section as SQL code. The SQL code responsible for this mechanism is generated automatically by GRAVITY during data retrieval, narrowing the data stream accordingly.