shrayud
(Shrayus)
April 2, 2021, 12:18pm
1
Hi
I want to keep a SQL code in a string variable. I will pass the variable as a type into activity in browser.
Since the SQL already has “” in it’s showing compilation error. SS are attached. Kindly suggest how can I store an SQL code in string variable:
Hello,
Hope this might help:
Hello all, I am trying to execute a dynamic SQL query (SQLite), which looks like this:
“SELECT address
FROM Clients
WHERE client = ‘(varClientId)’”
(varClientId) is a place holder for what would be my string variable.
Except it’s wrong, because I get an error. I already tried ‘$[variable_name]’, but it returns an empty result.
Furthermore I tried :
“SELECT address
FROM Clients
WHERE client = “+”'”+varClientID+“'”+"
But seems like you have to execute one string command.
Thank you,
shrayud
(Shrayus)
April 3, 2021, 6:52am
3
Hi this does not answer my query.
I have a SQL code snippet of the below format:
SELECT *
FROM table
WHERE date < todate(date , “dd/mm/yyyy”)
Now I want to store the above in a variable. How should I do it, if I put in string due to “dd/mm/yyyy” this will come as an error.
Thanks. Hope I have explained my situation.
Hi @shrayud
Kindly try the below and let me know whether it’s working or not.
Example: {name:““Your_wording_here””},
Give two double quotes each and try.
Thanks.
shrayud
(Shrayus)
April 5, 2021, 5:38am
5
Hi Vinesh,
This is still not working.
Hello, I am trying to do the same thing as you. Did you ever figure out how to do it?
shrayud
(Shrayus)
November 10, 2021, 6:11am
7
I dropped this project, so the issue remains un-solved. One idea I have is to keep “” on all lines. And separating each line by +
jeevith
(Jeevith Hegde, Ph.D.)
November 10, 2021, 6:33am
8
Hi @shrayud and @aphrodite123 ,
Alternative 1:
You can remove all double quotes "YOURVALUE"
from you SQL query string and instead use single quotes 'YOURVALUE'
as atleast Microsoft SQL does support single quotes in the query.
Alternative 2: Recommended way
An even more elegant way to achieve this is to just call a stored-procedure and you will entierly avoid this issue.
This way if you need to add any new logic into the query, you will not need to edit the robot. You will only need to edit your stored procedure in SQL Studio or equivalent editor.
If you pass variables in your query via UiPath your stored procedure can consume them as well. You can read more about how to call a stored procedure here : SQL Stored procedure Passing Parameters To fetch particular records - Help / Activities - UiPath Community Forum If you do not have paramters you only need to call the stored procedure.
Hope this helps you and others.