'How to validate the output of "Execute a SQL query" action in Azure Logic App

I have created an Azure Logic App by adding Execute a SQL query (V2) action. In the Execute a SQL query action, I have used the following query to get the specific column data.

select XXXX from [dbo].[XXXX] where XXXX=@{triggerBody()?['XXXX']?['XXXX']}

I’m getting the column data by using the following expression:

body('Execute_a_SQL_query_(V2)')?['resultsets']?['Table1'][0][<'Name of table column'>]

But for some scenarios Execute a SQL query action returns the following response:

{
  "ResultSets": {},
  "OutputParameters": {}
}

Whenever Execute a SQL query action returns empty response, then I'm getting the following error:

InvalidTemplate. Unable to process template language expressions in action 'Set_variable' inputs at line '0' and column '0': 'The template language expression 'int(body('Execute_a_SQL_query_(V2)')?['resultsets']?['Table1'][0]['XXXX'])' cannot be evaluated because property '0' cannot be selected

So, can anyone suggest me how to validate the “ResultSets” object is null or not?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source