我一直在努力从返回引用光标的 oracle 存储函数中获取结果集。
以下是 Oracle 存储函数的声明:
TYPE GetInspectorCursor IS REF CURSOR;
FUNCTION GetInspectorInformation
(inUserID IN inspectortable.userid%type,
inPassword IN inspectortable.password%type,
inCompanyID IN inspectortable.cid%type,
inSubCompanyID in inspectortable.scid%type,
outErrorcode OUT NUMBER)
RETURN GetInspectorCursor;
这是我获取结果集的 c# 程序:
String connString = "DATA SOURCE=PEOPLE.WORLD;PASSWORD=password;PERSISTSEC CURITY INFO=True;USER ID=userid";
DataSet ds;
OracleDataAdapter myAdapter = null;
Oracle.DataAccess.Types.OracleRefCursor refCursor = null;
OracleConnection myCon = new OracleConnection(connString);
String commandText = "schema.package.GetInspectorInformation";
OracleCommand cmd = new OracleCommand(commandText, myCon);
cmd.CommandType = CommandType.StoredProcedure;
// inpectorID
OracleParameter param = new OracleParameter();
param.OracleDbType = OracleDbType.Char;
param.Direction = ParameterDirection.Input;
param.Value = "JOHN";
cmd.Parameters.Add(param);
// inspector Password
OracleParameter param2 = new OracleParameter();
param2.OracleDbType = OracleDbType.Char;
param2.Direction = ParameterDirection.Input;
param2.Value = "12345";
cmd.Parameters.Add(param2);
// VALUE 1
OracleParameter param3 = new OracleParameter();
param3.OracleDbType = OracleDbType.Char;
param3.Direction = ParameterDirection.Input;
param3.Value = "VA1";
cmd.Parameters.Add(param3);
// VALUE 2
OracleParameter param4 = new OracleParameter();
param4.OracleDbType = OracleDbType.Char;
param4.Direction = ParameterDirection.Input;
param4.Value = "VA2";
cmd.Parameters.Add(param4);
// outParam Error Code
OracleParameter param5 = new OracleParameter();
param5.OracleDbType = OracleDbType.Decimal;
param5.Direction = ParameterDirection.Output;
//param5.IsNullable = true;
cmd.Parameters.Add(param5);
OracleParameter param6 = new OracleParameter();
param.ParameterName = "RefCursor";
param6.OracleDbType = OracleDbType.Object;
param6.OracleDbTypeEx = OracleDbType.RefCursor;
param6.Direction = ParameterDirection.ReturnValue;
///param6.IsNullable = false;
cmd.Parameters.Add(param6);
myCon.Open();
cmd.ExecuteNonQuery();
refCursor = (Oracle.DataAccess.Types.OracleRefCursor)cmd.Parameters["RefCursor"].Value;
myAdapter = new OracleDataAdapter("", myCon);
ds = new DataSet("testDS");
myAdapter.Fill(ds, refCursor);
// Clean up
cmd.Dispose();
myCon.Close();
myCon.Dispose();
在 myCon.Open() 调用中,我得到:
ORA-06550: line 1, column 15:
PLS-00306: wrong number or types of arguments in call to 'GETINSPECTORINFORMATION'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
有人会善意地节省一些脑细胞,然后告诉我错误传递了什么/哪个参数吗?
谢谢!!!!