cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JC_D4B
Level: Powered On

check if a record exists in SQL and create or modify it

Hi all,

 

I have a problem with the SQL connector. I want to check if one row exists in a table and then with a control action insert the new value or modify the existing one, I used the following expression:

equals(length(body('Get_row_(V2)')?['Value']),0),  but it doesn´t work, the error shown is:
error1.jpg
and the part of the flow that doesn´t work:
error2.jpgI also changed ['Value'] for the primary key of the table ['TicketID'] but it still doesn´t work, it returns another error message. 
any help will be appreciated.
 
Thank you in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: check if a record exists in SQL and create or modify it

Hi @JC_D4B ,

 

Yes, you could take a try with Filter Array to achieve your needs

Please let me know if your problem could be solved.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: check if a record exists in SQL and create or modify it

Hi @JC_D4B ,

 

The error message told that the template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'.

I have made a test on my side and the "body('Get_row_(V2)')?['Value']" would alwyas be null.

 

If your want to acheck if a record is exists in the SQL table, you couldn't achieve your requirement with the expression that you provided.

 

If the record is not in the SQL table, the "Get Row" action would run failed with error message "Item Not Found", so you could configure the "Insert row" action to run after the "Get Row" action has run successfully, and configure the "Update row" action to run after the "Get Row" action has run failed.

1.png

2.png

Please let me know if your problem could be solved.

 

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

JC_D4B
Level: Powered On

Re: check if a record exists in SQL and create or modify it

Dear Alice v-alzhan-msft

 

I thought about this, and I have used it in other flows for internal use, the question is that if I do this as you suggest when the flow insert a Row, at the end of the flow the execution status is failure, and it is not true, it has inserted the row, so finally, the customer won´t be sure if the flow has failed or if it is an insertion.

 

Maybe I have to use Get rows and use a filter to evaluate the array.

 

Regards,

Juanjo

Community Support Team
Community Support Team

Re: check if a record exists in SQL and create or modify it

Hi @JC_D4B ,

 

Yes, you could take a try with Filter Array to achieve your needs

Please let me know if your problem could be solved.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,060)