// This module is included in the following assemblies:
// as_connecting-to-databases.adoc

[id='adding-db-connection-start_{context}']
= Obtaining database records to trigger integration execution 

To trigger execution of an integration based on the result of invoking a SQL
statement or a SQL stored procedure, choose a database connection as the 
integration's start connection. 

.Prerequisite
You created a database connection. 

.Procedure

. In the {prodname} panel on the left, click *Integrations*.
. Click *Create Integration*.
. On the *Choose a connection* page, click the
database connection that you want to use to start an integration.
. On the *Choose an action* page, select one of the following:
+
* *Periodic SQL invocation* obtains data by periodically invoking the
SQL statement that you specify.
+
Note that the Database Connector accepts most basic SQL syntax. If you want to use a complex SQL statement, you should use a stored procedure instead since the Database Connector does not validate the SQL syntax in a stored procedure.        
* *Periodic stored procedure invocation* obtains data by periodically invoking
the stored procedure that you specify or select.
. If you selected *Periodic SQL invocation*, in the *Query* field,
enter a SQL `SELECT` statement or some other standard SQL statement that 
obtains one or more records. For 
example: `*SELECT * from my_db_table*`.
The database table that contains the data you want must already exist.
+
If you selected *Periodic stored procedure invocation*, in the
*Procedure name* field, select or enter the stored procedure to
invoke to obtain the data of interest. The stored procedure you specify must
already exist. The database administrator should have created any stored
procedures you need to use in an integration.
. In the *Period* field, enter an integer and indicate whether the unit is 
milliseconds, seconds, 
minutes, hours, or days. For example, if you specify `5 minutes` then
the connection invokes the specified statement or stored procedure every
five minutes.
. Click *Next*.

.Limitations on the use of SQL extensions
SQL statements that you enter in the *Query* field must be standard SQL constructs. 
{prodname} does not recognize or parse SQL extensions such as Procedural Language/PostgreSQL (PL/pgSQL) 
or Oracle Procedural Language Extensions to SQL (PL/SQL). 
However, you can use SQL extensions within stored procedures.
 

.Result
{prodname} tries to validate the connection, which includes
checking that a specified SQL statement is syntactically correct and
confirming that the statement or stored procedure target data exists. If
verification is successful then {prodname} adds the start connection to
the integration. If verification fails then {prodname} displays a message
about the problem. Update your input as needed and try again.
