How to changes values dynamically in sql query, Nee supply values through parameters.
"SELECT WIID, Description,Type,Status
FROM work_Items
WHERE Type = 'WI2';
"
How to changes values dynamically in sql query, Nee supply values through parameters.
"SELECT WIID, Description,Type,Status
FROM work_Items
WHERE Type = 'WI2';
"
Replace
"SELECT WIID, Description,Type,Status
FROM work_Items
WHERE Type = 'WI2';
"
with
"SELECT WIID, Description,Type,Status
FROM work_Items
WHERE Type = '"+in_type+"';
"
Like this - adapt to your specific case indeed.
// Using variables in SQL command
“SELECT * FROM @tableName WHERE ID = @id”
The queries I am Reading from Excel. so do I change dynamically .
@Yoichi @Anil_G @supermanPunch @Gokul001
Thank in advance
As you are reading from excel it would be good to inlcude places holders and use replace functions
eg: in excel have query as Select * from Table Where Date = '<DATE>'
In code you can use Row("ColumnName").ToString.Replace("<DATE>",actualDate)
cheers
Getting error like below.
Please print the value using log message and check if the statement looks proper
Is actualDate value correct
cheers
Value is there
There is no problem with that. You can get the query from wherever you want.
Only the query parameter should not be quoted.
And indeed the value in actualDate string variable must be propperly formated - which as I can see you have.
Select * from Acme_data Where Date = @Date
Cheers
I want you to print whole query string …like whatever is there in run query to check where the issue lies…as per error there might be one more extra equals or so
Cheers
Make sure the query in excel is a single continues line, i.e. wrap text is not applied.
What database system you work with?
The database type I am using “Postgresql”
I am not familiar with postgres but seems it is using $ instead of @
So the query should look like
Select * from Acme_data Where Date = $Date
If it doesn’t work you should use the Approach #1 from
Cheers
$ symbol is also not working
Approach #1 Is only for INSERT/UPDATE/SELECT not for Where condition.
Not realy. Approach #1 means that you build your SQL command in a string variable and pass this string variable to “Run Query” activity. It is what @Anil_G wrote before.
For debug purposses I recommend print the mySQL before executing.
e.g.
myQueryString = "Select * from Acme_data Where Date = '<myDate>'"
myDateString = "2023-07-11"
mySQL = myQueryString.replace("<myDate>", myDateString)
“Run Query”
Alternatively have look at this
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.