Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Gespeicherte Prozedur ausführen
In diesem Beispiel wird gezeigt, wie Sie eine gespeicherte Prozedur ausführen, wenn Sie eine Datenbankverbindung verwenden.
In diesem Beispiel wird davon ausgegangen, dass Sie mit den folgenden Konzepten vertraut sind:
Alle gespeicherten Prozeduren in einer Datenbankverbindung werden in der Connector-Aufgabe als Aktionen angezeigt. Eine Aktion ist eine Funktion erster Klasse, die über die Connector-Benutzeroberfläche für die Integration verfügbar gemacht wird. Mit Aktionen können Sie Änderungen an einer Entität oder Entitäten vornehmen und je nach Connector variieren. Es ist jedoch möglich, dass ein Connector keine Aktionen unterstützt. In diesem Fall ist die Actions-Liste leer.
Die folgenden Connectors unterstützen gespeicherte Prozeduren:
Angenommen, Sie haben eine MySQL-Datenbank mit der folgenden gespeicherten Prozedur, die die Informationen eines Kunden aus der Tabelle customers abrufen:
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
Diese gespeicherte Prozedur gibt den Namen und die E-Mail-Adresse für den angegebenen Kunden zurück. Er nimmt die Kundennummer über die Eingabevariable p_customer_id entgegen und gibt den Namen und die E-Mail-Adresse in den Ausgabevariablen p_name und p_email zurück.
Angenommen, Sie möchten den Namen und die E-Mail-ID des Kunden mit customer_id=1001 abrufen. Gehen Sie dazu so vor:
Klicken Sie im Bereich Konfiguration auf Aufgabe konfigurieren, um den Bereich Connector-Aufgabe konfigurieren zu öffnen.
Konfigurieren Sie die Connectors-Aufgabe so, dass die Verbindung verwendet wird, die Sie in Schritt 1 erstellt haben.
Wählen Sie in der Spalte Verbindung die erforderliche Verbindung aus der Liste der verfügbaren Verbindungen aus.
Nachdem Sie eine Verbindung ausgewählt haben, wird die Spalte Typ mit den Werten Entities und Actions angezeigt. Alle gespeicherten Prozeduren werden unter Aktionen aufgeführt.
Wählen Sie Aktionen > get_customer_info aus.
Klicken Sie auf Fertig, um die Verbindungskonfiguration abzuschließen und den Bereich zu schließen.
Klicken Sie auf das Aufgabenelement Connectors und dann im Bereich Task Input auf connectorInputPayload.
Geben Sie die folgende JSON-Nutzlast in das Feld Default Value ein:
{
"customer_id": 1001
}
Klicken Sie in der Symbolleiste des Integrationseditors auf die Schaltfläche Testen, um die Integration auszuführen.
Wenn die Integration erfolgreich ausgeführt wird, hat die Variable connectorOutputPayload eine JSON-Nutzlast, die in etwa so aussieht:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eStored procedures in a database connection are accessible as actions within the Connector task in Application Integration.\u003c/p\u003e\n"],["\u003cp\u003eConnectors such as BigQuery, Cloud SQL, MySQL, Oracle DB, PostgreSQL, SQL Server, MariaDB, AlloyDB, Snowflake, and Redshift support stored procedures.\u003c/p\u003e\n"],["\u003cp\u003eTo execute a stored procedure, you need to configure a Connector task with a database connection and select the desired procedure from the list of available actions.\u003c/p\u003e\n"],["\u003cp\u003eInput parameters for a stored procedure can be specified through a JSON payload in the Connector task's \u003ccode\u003econnectorInputPayload\u003c/code\u003e section.\u003c/p\u003e\n"],["\u003cp\u003eThe output of a successfully executed stored procedure will be returned as a JSON payload in the \u003ccode\u003econnectorOutputPayload\u003c/code\u003e variable.\u003c/p\u003e\n"]]],[],null,["# Execute a stored procedure\n==========================\n\nThis example shows how to run a stored procedure when you are using a database connection.\nThe example assumes that you are familiar with the following concepts:\n\n- [Creating integrations using Application Integration](/application-integration/docs/try-sample-integration-ecommerce)\n- [Connector task](/application-integration/docs/configure-connectors-task)\n- [Integration Connectors](/integration-connectors/docs/overview)\n- Database stored procedures\n\nAll stored procedures in a database connection are exposed to you as actions in the\n[Connector task](/application-integration/docs/configure-connectors-task). An action is a first\nclass function that is made available to the integration through the connector interface. Actions\nlet you make changes to an entity or entities, and vary from connector to connector. However, it is possible\nthat a connector doesn't support any action, in which case the `Actions` list will be empty.\n\nThe following connectors support stored procedures:\n\n- [BigQuery](/integration-connectors/docs/connectors/bigquery/configure)\n- [Cloud SQL - MySQL](/integration-connectors/docs/connectors/cloudsqlformysql/configure)\n- [Cloud SQL - PostgreSQL](/integration-connectors/docs/connectors/cloudsqlforpostgresql/configure)\n- [Cloud SQL - SQL Server](/integration-connectors/docs/connectors/cloudsqlforsqlserver/configure)\n- [MySQL](/integration-connectors/docs/connectors/mysql/configure)\n- [Oracle DB](/integration-connectors/docs/connectors/oracledb/configure)\n- [PostgreSQL](/integration-connectors/docs/connectors/postgresql/configure)\n- [SQL Server](/integration-connectors/docs/connectors/sqlserver/configure)\n- [MariaDB](/integration-connectors/docs/connectors/mariadb/configure)\n- [AlloyDB](/integration-connectors/docs/connectors/alloydb/configure)\n- [Snowflake](/integration-connectors/docs/connectors/snowflake/configure)\n- [Redshift](/integration-connectors/docs/connectors/redshift/configure)\n\n### Example\n\nConsider you have a MySQL database which has the following stored procedure that gets a\ncustomer's information from the `customers` table: \n\n```\nCREATE PROCEDURE get_customer_info\n(IN p_customer_id INT, OUT p_name VARCHAR(50), OUT p_email VARCHAR(255))\nBEGIN\n SELECT name, email INTO p_name, p_email\n FROM customers\n WHERE id = p_customer_id;\nEND\n```\n\nThis stored procedure returns the name and email for the specified customer. It takes\nin the customer ID through the `p_customer_id` input variable and returns the\nname and email in the `p_name` and `p_email` output variables, respectively.\n\nNow suppose you want to get the name and email id of the customer with `customer_id=1001`,\nyou must do the following tasks:\n\n1. Create a [connection to your MySQL database](/integration-connectors/docs/connectors/mysql/configure).\n2. Open or create a new [integration](/application-integration/docs/quickstarts).\n3. Add the [Connectors task](/application-integration/docs/configure-connectors-task) to your integration.\n4. In the **Configuration** section, click **Configure task** to open the **Configure connector task** pane.\n5. Configure the Connectors task to use the connection you created in step 1.\n 1. In the **Connection** column, select the required connection from the list of available connections.\n\n\n After you select a connection, the **Type** column appears with the values\n `Entities` and `Actions`. All the stored procedures will be listed\n in **Actions**.\n 2. Select **Actions \\\u003e get_customer_info**.\n 3. Click **Done** to complete the connection configuration and close the pane.\n6. Click the `Connectors` task element, and then click `connectorInputPayload` in the `Task Input` section.\n7. Specify the following JSON payload in the `Default Value` field: \n\n ```\n {\n \"customer_id\": 1001\n }\n ```\n8. Click the **Test** button in the integration editor toolbar to run the integration.\n\n If the integration runs successfully, the `connectorOutputPayload`\n vairable will have a JSON payload similar to the following: \n\n ```\n {\n \"name\": \"John\",\n \"email\": \"john@test.com\"\n }\n ```"]]