I have an parameterized SQL statement that uses the IN clause in order to update multiple records with one query. It is an integer field, the RID (record ID), to do the update. If I pass only one RID it works but if I pass multiple values I get Error: ORA-01722: invalid number.
This is the code:
sbQuery.Append("update EXC_LOG set supv_emp_id=:userId, status=:exceptionStatus, supv_comments=:exceptionComment ");
sbQuery.Append("where RID in (:rid)");
ctx.Database.ExecuteSqlCommand(sbQuery.ToString(),
new OracleParameter("userId", UserId),
new OracleParameter("exceptionStatus", exceptionStatus),
new OracleParameter("exceptionComment", comment),
new OracleParameter("rid", rid));
If I pass in one value RID it works but if I pass in multiples comma separated (ex: 1234,5566,8899) I get the Invalid Number error.
How can I pass in multiple integer values when using parameters?
,and.? Not sure what kind of framework you are using, but maybe theOracleParameterobject parses your input1234,5566,8899as a single number and not multiple entities. Depending on system and/or NLS settings that number could be interpreted several ways (as in "American" vs. "European" meaning of , and . in numbers). Seen this stuff lead to similar errorsridvalue? Maybe you can use a collection type instead of a string (andmember ofinstead ofin)? Or use this workaround.in(), but you can't have a single string that happens to contain comma-separated values, which is what you are doing. Well, not without extra handling.