# Execute a stored procedure

This example shows how to run a stored procedure when you are using a database connection.
The example assumes that you are familiar with the following concepts:

- [Creating integrations using Application Integration](https://docs.cloud.google.com/application-integration/docs/try-sample-integration-ecommerce.md.txt)
- [Connector task](https://docs.cloud.google.com/application-integration/docs/configure-connectors-task.md.txt)
- [Integration Connectors](https://docs.cloud.google.com/integration-connectors/docs/overview.md.txt)
- Database stored procedures

All stored procedures in a database connection are exposed to you as actions in the
[Connector task](https://docs.cloud.google.com/application-integration/docs/configure-connectors-task.md.txt). An action is a first
class function that is made available to the integration through the connector interface. Actions
let you make changes to an entity or entities, and vary from connector to connector. However, it is possible
that a connector doesn't support any action, in which case the `Actions` list will be empty.

The following connectors support stored procedures:

- [BigQuery](https://docs.cloud.google.com/integration-connectors/docs/connectors/bigquery/configure.md.txt)
- [Cloud SQL - MySQL](https://docs.cloud.google.com/integration-connectors/docs/connectors/cloudsqlformysql/configure.md.txt)
- [Cloud SQL - PostgreSQL](https://docs.cloud.google.com/integration-connectors/docs/connectors/cloudsqlforpostgresql/configure.md.txt)
- [Cloud SQL - SQL Server](https://docs.cloud.google.com/integration-connectors/docs/connectors/cloudsqlforsqlserver/configure.md.txt)
- [MySQL](https://docs.cloud.google.com/integration-connectors/docs/connectors/mysql/configure.md.txt)
- [Oracle DB](https://docs.cloud.google.com/integration-connectors/docs/connectors/oracledb/configure.md.txt)
- [PostgreSQL](https://docs.cloud.google.com/integration-connectors/docs/connectors/postgresql/configure.md.txt)
- [SQL Server](https://docs.cloud.google.com/integration-connectors/docs/connectors/sqlserver/configure.md.txt)
- [MariaDB](https://docs.cloud.google.com/integration-connectors/docs/connectors/mariadb/configure.md.txt)
- [AlloyDB](https://docs.cloud.google.com/integration-connectors/docs/connectors/alloydb/configure.md.txt)
- [Snowflake](https://docs.cloud.google.com/integration-connectors/docs/connectors/snowflake/configure.md.txt)
- [Redshift](https://docs.cloud.google.com/integration-connectors/docs/connectors/redshift/configure.md.txt)

### Example

Consider you have a MySQL database which has the following stored procedure that gets a
customer's information from the `customers` table:

```
CREATE PROCEDURE get_customer_info
(IN p_customer_id INT, OUT p_name VARCHAR(50), OUT p_email VARCHAR(255))
BEGIN
    SELECT name, email INTO p_name, p_email
    FROM customers
    WHERE id = p_customer_id;
END
```

This stored procedure returns the name and email for the specified customer. It takes
in the customer ID through the `p_customer_id` input variable and returns the
name and email in the `p_name` and `p_email` output variables, respectively.

Now suppose you want to get the name and email id of the customer with `customer_id=1001`,
you must do the following tasks:

1. Create a [connection to your MySQL database](https://docs.cloud.google.com/integration-connectors/docs/connectors/mysql/configure.md.txt).
2. Open or create a new [integration](https://docs.cloud.google.com/application-integration/docs/quickstarts.md.txt).
3. Add the [Connectors task](https://docs.cloud.google.com/application-integration/docs/configure-connectors-task.md.txt) to your integration.
4. In the **Configuration** section, click **Configure task** to open the **Configure connector task** pane.
5. Configure the Connectors task to use the connection you created in step 1.
   1. In the **Connection** column, select the required connection from the list of available connections.


      After you select a connection, the **Type** column appears with the values
      `Entities` and `Actions`. All the stored procedures will be listed
      in **Actions**.
   2. Select **Actions \> get_customer_info**.
   3. Click **Done** to complete the connection configuration and close the pane.
6. Click the `Connectors` task element, and then click `connectorInputPayload` in the `Task Input` section.
7. Specify the following JSON payload in the `Default Value` field:

   ```
   {
   "customer_id": 1001
   }
   ```
8. Click the **Test** button in the integration editor toolbar to run the integration.

   If the integration runs successfully, the `connectorOutputPayload`
   vairable will have a JSON payload similar to the following:

   ```
   {
   "name": "John",
   "email": "john@test.com"
   }
   ```