I am trying to execute a SQL query where I have to pass a parameter dynamically. I read multiple posts online where it was suggested to list the parameter as follows in the SQL query - @parameter or :parameter or ‘@parameter’. I tried all three ways but I keep getting the error saying illegal variable name/number. I also tried creating a separate string with the parameter and using the string name in place of the query. None of these methods have worked so far. I would really appreciate if someone could suggest an alternate solution to executing a query dynamically.
My query is as follows -
“SELECT MIN(CNUMBER),MAX(CNUMBER),COUNT(1),SUM(NET_AMT)
FROM I.AB
WHERE DATE = ‘parameter or dynamic input date’”
Please let me know if anyone has any thoughts! Appreciate it!