I am facing an issue trying to use variable binding with a pipeline function in Oracle. I am using ODP .NET for connecting to the database.

If you want to be familiar with PIPELINED functions, you can read this blog.

I have very similar code with a difference. My function takes in two parameters that I need to pass to get the table. This is working in SQLPLUS without any issues.

In my C# code, however things change. My function no longer returns a recordset (data reader), if I use the standard method of assigning the parameters.

The code will work if I concat the variables in a string.

Here is the example that doesn't work.
c# Code:
  1. static OracleDataReader fetchData(OracleConnection oc, string strPONumber)
  2.         {
  3.             try
  4.             {
  5.                 OracleCommand od = oc.CreateCommand();
  6.                 od.CommandType = System.Data.CommandType.Text;
  7.                 od.CommandText = "select * from table(pkg_fetchPOInfo.getPORowsTable(:1,:2))";
  8.                 OracleParameter op1 = new OracleParameter();
  9.                 op1.ParameterName = "1";
  10.                 op1.OracleDbType = OracleDbType.Varchar2;
  11.                 op1.Direction = System.Data.ParameterDirection.Input;
  12.                 op1.Size = 7;
  13.                 op1.Value = strPONumber;
  14.                 od.Parameters.Add(op1);
  15.                
  16.                 OracleParameter op2 = new OracleParameter();
  17.                 op2.ParameterName = "2";
  18.                 op2.OracleDbType = OracleDbType.Varchar2;
  19.                 op2.Direction = System.Data.ParameterDirection.Input;
  20.                 op2.Size = 3;
  21.                 op2.Value = "US";
  22.                 od.Parameters.Add(op2);
  23.  
  24.                 OracleDataReader or = od.ExecuteReader();
  25.                 return or;
  26.             }
  27.             catch (Exception e)
  28.             {
  29.                 Console.WriteLine("Error " + e.ToString());
  30.                 return null;
  31.             }
  32.         }

Here is the example that does.
c# Code:
  1. static OracleDataReader fetchData(OracleConnection oc, string strPONumber)
  2.         {
  3.             try
  4.             {
  5.                 OracleCommand od = oc.CreateCommand();
  6.                 string formSQL = "Select * from table(pkg_fetchPOInfo.getPORowsTable('"+strPONumber+"','US'))";
  7.                 od.CommandType = System.Data.CommandType.Text;
  8.                 od.CommandText = formSQL;
  9.                 OracleDataReader or = od.ExecuteReader();
  10.                 return or;
  11.             }
  12.             catch (Exception e)
  13.             {
  14.                 Console.WriteLine("Error " + e.ToString());
  15.                 return null;
  16.             }
  17.         }