I'm having a problem where I don't know how I'm supposed to pass in an Oracle parameter where the C# type is a string
and the Oracle type is a Varchar2
.
Currently I'm passing in this string
as CMS','ABC
thinking that Oracle will add in the ''
that surround this string
making it a varchar2
that looks like 'CMS','ABC'
.
This works for a single string
like CMS
but when the value is something longer, like something typically in a IN (list)
command the parameter won't be passed in correctly.
This is the code I'm referring too.
string sql = 'SELECT name FROM Pers p WHERE p.FirstName IN (:names)';
The below works when the value of :names
being passed in is CML
without any quotes.
OracleParameter param = new OracleParameter(":names", OracleDbType.Varchar2, "CML", ParameterDirection.Input);
Below doesn't work when the value of :names
being passed in is CML','ABC
with quotes on the inside.
OracleParameter param = new OracleParameter(":names", OracleDbType.Varchar2, "CML','ABC", ParameterDirection.Input);
Why is that?
Does Oracle add in single quotes around the parameter when it's passed into the sql statement? Why doesn't it add quotes around the second case?