我有一個Oracle函數返回一個記錄集。 我向Oracle函數中引入了參數,導致前端代碼出現故障。在Oracle軟件包中使用參數。 ODP .NET
這是我的前端代碼。
OracleCommand od = oc.CreateCommand();
od.CommandType = System.Data.CommandType.Text;
od.CommandText = " select * from table(pkg_fetchPOInfo.getPORowsTable(:1,:2))";
//od.CommandText = "pkg_fetchPOInfo.getPORowsTable";
//od.CommandType = System.Data.CommandType.TableDirect;
OracleParameter op1 = new OracleParameter();
op1.ParameterName = "1";
op1.OracleDbType = OracleDbType.Varchar2;
op1.Direction = System.Data.ParameterDirection.Input;
op1.Size = 6;
op1.Value = strPONumber;
od.Parameters.Add(op1);
OracleParameter op2 = new OracleParameter();
op2.ParameterName = "2";
op2.OracleDbType = OracleDbType.Varchar2;
op2.Direction = System.Data.ParameterDirection.Input;
op2.Size = 3;
op2.Value = "US";
od.Parameters.Add(op2);
如果我在前端SQLPLUS執行查詢,我得到一個記錄集。 如果我從軟件包和前端代碼中刪除參數,此代碼將起作用。
select * from table(pkg_fetchPOInfo.getPORowsTable('1007446','US')); - SQLPLUS中的工作。
select * from table(pkg_fetchPOInfo.getPORowsTable()); - 在兩個地方工作。
我是不正確地分配參數嗎?
一兩件事:我發現,如果我不使用參數綁定,它會與這方面的工作碼。 string formSQL =「Select * from table(pkg_fetchPOInfo.getPORowsTable(''+ strPONumber +'','US'))」; od.CommandType = System.Data.CommandType.Text; od.CommandText = formSQL; – abhi 2010-08-03 18:11:00
如果您更詳細地解釋「正在進行干擾」 – 2013-02-15 15:19:06