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?
You can use the below expression and conditions to evaluate if the ResultSets
are empty
and then proceed with further steps.
equals(string(outputs('Execute_a_SQL_query_(V2)')?['body']['ResultSets']),'{}')
Example:
If its true
, that means it empty set.