Skip to content

Martini Data Integration SQL Database Stored Procedures

Overview

Stored procedures allow encapsulation of complex SQL statements within a callable routine. They are useful for performing repetitive tasks, ensuring data integrity, and improving performance. In Martini, stored procedures from your SQL databases can be invoked through SQL Services, facilitating seamless integration with your workflows.

Creating a Stored Procedure

Creating a stored procedure in your database is a straightforward process. Below is an example of creating a simple stored procedure that retrieves all records from a table named Pets:

1
CREATE PROCEDURE GetAllPets AS SELECT * FROM Pets;

Executing this command in your SQL database environment will create the GetAllPets stored procedure.

Testing the Stored Procedure

After creating the stored procedure, it's important to test it to ensure it works as expected.

Connecting the Database to Martini

To invoke the stored procedure from Martini:

  1. Add Database Connection: Ensure that your database is connected to Martini. Refer to the article on adding database connections in Martini for guidance.
  2. Create a New SQL Service: Navigate to the SQL Service creation area in Martini and select the appropriate database connection.

Executing Stored Procedures in Martini

With the SQL Service set up:

  1. Locate the Stored Procedure: In the SQL Service editor, expand the Schema tree, then the Functions section to find your stored procedure.
  2. Execute the Stored Procedure: Enter the call command as you would in the database:

    1
    CALL GetAllPets;
    
  3. View the Results: After executing the stored procedure, you should see the results displayed in Martini, similar to how they appear in your database management tool.