Use returned data from SQL query

Eric Krasner - US 61 Reputation points
2022-04-05T22:33:58.627+00:00

I am querying a SQL DB which returns a single row of data with 5 fields. I want to use one of the fields in the next step, which is a HTTP webhook. It forces me into a foreach loop and then errors due to the returned results not being in an array. Help please

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
{count} votes

Answer accepted by question author
  1. MayankBargali-MSFT 70,986 Reputation points Moderator
    2022-04-06T13:10:03.53+00:00

    @Eric Krasner - US Thanks for reaching out. Looks like you are using Get row v2 action as you mentioned that it returns a single row. Please confirm if my understanding is correct.

    In that case, you can directly use the dynamic result of your Get row V2 action in any of the next action in your workflow. You don't have to use the Parse Json action in this case as your output from the action is already tokenized for you as below.
    190591-image.png

    In case if you have used the Get rows v2 action which returns a list of rows as the array then it is expected behavior and if you are using any fields it will automatically create for each loop for you to get the current item from the output list.

    There are two ways to handle this either you can create the rest of your workflow inside the foreach loop (without parse json action as the output will already be tokenized for you inside the loop) as the return is array or you can leverage the actions function as below to get the first item from the array along with the column name value which you need.

    In my case in the below screenshot, the action name is Get rows (v2) (space should be replaced by '_' when using inside actions and you can refer to the code view to get the name of your action), 0th item in the array and the column for which I want to get the value is LastName.

    actions('Get_rows_(V2)').outputs.body.value?[0]?['LastName']  
    

    190489-image.png

    Note: For reference I have used the variable for the testing purpose in the next action you can leverage the same actions function in any of your next actions to get the value.

    Feel free to get back to me if you need any assistance.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.