I've an Oracle
query where I need to get some data on the basis of some records (strings). I am using IN
clause and query is working fine in TOAD
with hardcoded data. But when I run that query through code (Dapper
) and pass those strings as Parameters, query always returns NULL/ Empty result.
Here is my query:
SELECT * FROM table WHERE id IN :lstIds
that's how I'm passing my data as parameter:
using (IDbConnection conn = new DBManager().connection)
{
conn.Open();
lstData = conn.Query<ViewModelData>(sqlGetData, new
{
lstIds = lstIdsParams
}).ToList();
conn.Dispose();
}
and this is my list of Ids, that I am passing as param
Even if I run this query with hardcoded data, it still does not work..
SELECT * FROM table WHERE id IN 'PL-0417-01301006-H01-D-00013#000013#18'
But if I run same query in TOAD with hardcoded data, it works fine and returns proper data. I don't know what I am doing wrong in code that is creating issue. Can anyone help me out here??
Best Answer
Your syntax is wrong you need parenthesis around the value(s)
Please remember not to post Images for data, queries and errors
db<>fiddle here