I know that this is an old question, but it is one of several in which the selected answer did not solve my problem, and I do not want to start another thread on this topic, so I will simply outline what I found in my travels in the hope that it might help someone.
I do not work very much with Oracle, but, like in SQL Server, it seems that to pass a table parameter, you need the corresponding UDT (user table), for which you have EXECUTE permissions (I may be wrong). This means that other answers involving the use of the built-in SYS UDT come with some load, and I could not figure out if it is really possible to pass the table to something that is not a PL / SQL stored procedure in the current version of ODP.net.
Secondly, the line parsing solution is an obstacle for all obvious reasons (it is impossible to cache the execution plan or, as Oracle calls it, it does not scale well, etc.)
Therefore, I spent quite a lot of time trying to execute the IN clause using a table parameter in datamart, for which I have only READ permission, before I was blinded by an obvious flash ( on the ASP.net forum no less ). It turns out that Oracle supports Xml queries βnatively,β so instead of passing an array of values, you can pass an XML list (if that's all you need). Again, I could be wrong, but it is treated as a valid binding parameter, and this is an example of how easy it is to use (vb.net, ADO.net, ODP.net using the NuGet package):
Dim xe As New XElement("l", New XElement("i", "ITEM-A"), New XElement("i", "ITEM-B")) Using conn As New OracleConnection(myConnectionString) conn.Open() Using cmd As OracleCommand = conn.CreateCommand() cmd.CommandType = CommandType.Text Dim query As String query = " SELECT s.FOO, q.BAR " & vbCrLf query &= " FROM TABLE1 s LEFT OUTER JOIN " & vbCrLf query &= " TABLE2 q ON q.ID = s.ID " & vbCrLf query &= " WHERE (COALESCE(q.ID, 'NULL') NOT LIKE '%OPTIONAL%') AND " query &= " (s.ID IN (" query &= " SELECT stid " query &= " FROM XMLTable('/l/i' PASSING XMLTYPE(:stid) COLUMNS stid VARCHAR(32) PATH '.')" query &= " )" query &= " )" cmd.CommandText = query Dim parameter As OracleParameter = cmd.Parameters.Add("stid", OracleDbType.NVarchar2, 4000) parameter.Value = xe.ToString Using r As OracleDataReader = cmd.ExecuteReader While r.Read() //Do something End While End Using End Using conn.Close()
This is more of an observation than a carefully studied solution, so please comment if there is anything inappropriate about this.
EDIT. When using this method, there seems to be a limit of 4000 characters (2000 if NVARCHAR), so I had to watch the search. Informative error message that you get if you go, "ORA-01460: conversion failed or unfounded requested"