Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:Write
Description:

This Snap invokes a stored procedure in the Azure SQL Database. If the procedure contains any OUT parameters, they are written to the output view.

ETL Transformations & Data Flow

This Snap enables the following ETL operations/flows:

Ideally, there is no data flow from the Snap to the database, however, the results computed in the store procedure or the result of queries executed in the stored procedure can be fetched by the Snap through output parameters.

Input & Output

  • InputThis Snap can have an upstream Snap that can pass a document output view. Such as Structure or JSON Generator. 
  • Output: The Snap has two output views-
    • Results set output view: Output document in the Result Set output view contains the result set of the stored procedure.
    • Output parameters output view : Output document in the output view contains a key-value pair for each output parameter. It will be an empty map document if there is no output parameter.


Prerequisites:The SP to be invoked must be created before executing the Snap.
Limitations and Known Issues:
Configurations:

Account & Access

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Azure SQL Account for information on setting up this type of account.

Views

InputThis Snap allows up to one input view. If an input view is defined, then values from an incoming document can be used as input parameters to the stored procedure.
OutputThis Snap has exactly two document output views, one regular output view, and one Result Set output view.
Error

This Snap has at most one error view and produces zero or more documents in the view.


Troubleshooting:

Ensure the input provided (Schema name and SP name) is correct.

Ensure the input parameters are provided correctly.

Settings

Label


Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Schema Name


The schema name where the procedure resides. The property is suggestible and will return all schemas of the DB.

Note

The values can be passed using the pipeline parameters but not the upstream parameter.

Example: dbo


Stored Procedure Name

Required. Stored procedure to execute. The property is suggestible and will return all procedures of the DB. If a package is defined, then it will only return the procedures of that package. If a schema is defined and no package is defined, then it will return all procedures of that schema.

Example: addSeventeen
Default value: [None] 


Parameter Values


Input Select the input parameter values for the stored procedure. The  If you define parameter values should be in order in the list that they appear in , you must do so in the same order as they appear in the stored procedure definition.

Example: Suppose there is a stored procedure named createGreeting.  It has three parameters p1,p2, and p3.  p1 and p2 are input parameters of type VARCHAR2.  Then there have to be two string values provided.  The first value goes to p1 and the second to p2.

Note
Quotation marks should not be used when setting input parameters unless they are part of the input value itself, since they are treated as escaped plain characters. For example, if the desired input value is TEST_VALUE1, the input parameter should be set as TEST_VALUE1, if you set it as "TEST_VALUE1", it will be recognized as \"TEST_VALUE1\".


Info

If you do not provide any parameters in the given Snap, you can view the required input parameters in the Target Schema of the upstream Mapper Snap. The parameters are dynamically populated based on the column keys of the stored procedure; you can map the parameters and pass them as an input to the Stored Procedure Snap.

Default value: [None]

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute


Basic Use Case

The following pipeline describes how the Snap functions in a pipeline: 

The Azure SQL Stored Procedure Snap invokes the Stored Procedure, Emp_Select_2

  


The Stored Procedure as created on the Azure SQL Database:

Code Block
Create PROCEDURE Emp_Select_2(
@emp_id INT    -- Input parameter 
)
AS
BEGIN
SELECT * FROM dbo.Emp_Details WHERE emp_id=@emp_id 
END


The value passed through the upstream:



The Azure SQL Stored Procedure Snap invokes the stored procedure EMP_Select_2:

The output parameters output preview:

The result set output preview:

Typical Snap Configurations

The key configuration for the Snap are:

The Azure SQL Stored Procedure Snap invokes a procedure Emp_Select  on the database.

 

The procedure as created on the Azure SQL database:

  • Without Expression: Directly passing the required values into the Azure SQL Stored Procedure Snap:

The Azure SQL Stored Procedure Snap invokes the stored procedure, EMP_Select, with the parameter values as provided through the upstream:

 

The upstream Snap passes the values for invoking the procedure:

The Stored Procedure Snap retrieves the Stored Procedure name ($SP_Name) dynamically from the Upstream and the Schema name (_Schema) from the pipeline parameters:

 The Result Set output view that displays the results (the details of the employee with the provided ID) of the procedure:

   


Advanced Use Case

The following describes a pipeline, with a broader business logic involving multiple ETL transformations, that shows how typically in an enterprise environment, stored procedure functionality is used. Pipeline download link below.

This pipeline reads and moves the files from the SQL Server database to the Azure SQL database for reporting purposes. In this use case, the SQl Server Select Snap reads five records whose salary range is 40000 - 50000. The pipeline invokes a stored procedure, Emp_Select_SP, that retrieves the employee IDs where the salary>@sal. The Mapper Snap maps the value 50000 to the target output, sal. The Stored Procedure Snap invokes the procedure that retrieves all the records whose salary is greater than 50000. 

 

  1. Extract: The SQL Server Select Snap reads the records from the SQL Server Database.

  2. Transform: The Mapper Snap maps the values to be used for the stored procedure.

  3. Load: The Bulk Load Snap loads the records into the Azure SQL table.

  4. Extract: The Azure SQL Stored Procedure Snap retrieves the records as set in the stored procedure code.


The Stored Procedure as created on the Azure SQL Database:

Code Block
Create PROCEDURE Emp_Select_SP (
@sal INT
)
AS 
BEGIN 
SELECT * FROM dbo.employee_sp WHERE salary>@sal 
END


The out preview (5 records) from the SQL Server Select Snap:

The Output preview from the Azure SQL Stored Procedure Snap:

(2 records with employee salary greater than 50000 are retrieved)

Downloads 

Attachments
oldfalse
patterns.*slp, *zip

Insert excerpt
Azure SQL Snap Pack
Azure SQL Snap Pack
nopaneltrue