Multiple values in SQL for Execute Query to excel

Hi I have got a problem with Execute Query activity. sometimes I got more than 1 values to search in SQL and then write in Excel.
with 1 value seems it works for me but with more than 1 values, it doesnt work. my excel shows nothing in there. Im assuming the code needs to change in here?
Eg in SQL - select street_no, phone_no from data where phone_no in (‘12345’, ‘A-2345’, ‘34567’)
but how do I write it in UiPath?
I got “select street_no, phone_no from data where phone_no in ('” + phone_no + “'”)

@koolrc812

In phoneNo string, join the strings like this

123’,‘345’,'234

If they are in a list then String.Join(“‘,’”,Yourlist)

cheers

I got that Write Line String.Join(“‘,’”,Yourlist) then Execute Query → Write Range
But not sure what to write in Execute Query

@koolrc812

you will write this

"select street_no, phone_no from data where phone_no in ('" + String.Join("','",Yourlist) + "')"

cheers

FileNames = String.Join(“,”,TxtFileName) → Write Line String.Join(“,”,TxtFileName).Split(“_“c).last → Execute Query “select street_no, phone_no from data where phone_no in ('” + String.Join(”‘,’”.TxtFileName) + “')”

With the error message TxtFileName is not a member of ‘String’.

FileName i declared it as String
TxtFileName declared as System.Collections.Generic.List<System.String>

did I put the wrong variable?

@koolrc812

You gave .txtfilename please remove dot and give comma

My mistake even i gave a dot extra

Cheers

Thanks. but now received the below error message

Why sometimes when running Execute Query shows Execute Query: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Sometimes I set Connect Timeout=5000 somestimes Connect Timeout=50000
so sometimes it works sometimes it doesnt work?

@koolrc812

For big queries it takes more time some times or if the connection is slow it might happen…just give more timeout to check and alternately add a retry scope so that even if it fails because of connection issues it retries

Cheers

Thanks heaps!!! your awesome!!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.