Logic App Runs Execute stored procedure (V2) twice if the procedure has a RAISERROR block
We observed an unusual behavior in our Logic App where the Execute Procedure action was being triggered twice. After investigating further, we found that if a RAISERROR statement is executed within the stored procedure, the Execute Procedure action gets invoked again from Logic App.
Has anyone else encountered this issue? Is this expected behavior, or is there a way to prevent the duplicate execution?
Steps to Reproduce execution of "Execute Stored Procedure (V2))" twice.
Very simple logic app
No retry policy set
Simple table and stored procedure
CREATE TABLE dbo.test(id INT IDENTITY(1,1), col_value VARCHAR(1000))
GO
CREATE OR ALTER PROC dbo.test_insert @val varchar(1000)
AS
INSERT INTO dbo.test(col_value)VALUES(@val)
RAISERROR(@val, 16, 1) /*Comment and Uncomment as needed*/
/* Please note that, the actual scenario is different where we need to throw the error when certain conditions are not met - this code block is just a sample*/
GO
--Run from SSMS
--EXEC dbo.test_insert @val = 'abc'
--Verify data
SELECT * FROM dbo.test ORDER BY 1 DESC
The action was called twice when the table results are seen.
Also, the SQL Profiler confirms there were 2 calls from Azure (Mashup Engine)