Azure SQL - Stored Procedure

Azure SQL - Stored Procedure

On this Page

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:

  • Works in Ultra Tasks.

  • Can invoke only SPs but not functions. For such functions, use Execute Snap.

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

Input

This 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.

Output

This 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.

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

 

Select the input parameter values for the stored procedure. If you define parameter values, 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.

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\".

If you do not provide any parameters in the given Snap, you can still 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]

Error rendering macro 'multiexcerpt-include-macro' : Page loading failed

Error rendering macro 'multiexcerpt-include-macro' : Page loading failed

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:

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: