I'm having trouble passing in a string to a function where the string is going to be used in an IN
clause.
The string looks like this:
OracleParameter p = new OracleParameter("'ABC','EEE','DDD','FFF'", val, OracleDbType.VarChar2, ParameterDirection.Input);
and the IN
clause in the PL/SQL function is something like this:
sqlString := 'WHERE SomeCd IN (' || in_Codes || ')'
So when the function executes you'll get this for the clause:
WHERE someCd IN ('ABC','EEE','DDD','FFF')
The problem is, I can't really test this in my IDE since in order to pass this in I would have to use an escape sequence to escape the single quotes. This leads to the string to either look like this:
'''ABC'',''EEE'',''DDD'',''FFF'''
which gets parsed as
''ABC'',''EEE'',''DDD'',''FFF''
q'['ABC','EEE','DDD','FFF']'
Which gets sent as
q'['ABC','EEE','DDD','FFF']'
to the function.
Neither of these will work correctly as the format of the string is now wrong.
How can I pass in this list to the function in the correct format? Do I have to use a varray or something?
EDIT:
The problem in general is: When I escape a single quote ''
within an escaped pair of single quotes ''''
, the escaped single quote ''
is being passed in to the function also.