存储过程包定义如下:
CREATE OR REPLACE PACKAGE JXZLPJ
IS
type arr is table of integer index by binary_integer;
procedure ceshi(reccount out int,v_arr out arr);
END JXZLPJ;
CREATE OR REPLACE PACKAGE BODY JXZLPJ
IS
procedure ceshi(reccount out int,v_arr out arr)
is
 cursor temp_xh is select xh from xj_xjb where xh like '19222%';
 temp_jj varchar2(10);
 i integer;
begin
 i:=0;
 select count(*) into reccount from xj_xjb where xh like '19222%';
 open temp_xh;
 loop
   fetch temp_xh into temp_jj;
   v_arr(i):=temp_jj;
   i:=i+1;
 end loop;
 close temp_xh;
end;
END JXZLPJ;
在 c#中 如何调用输出为table型的 过程 ?
我这儿是举的一个例子,实际应用中是要计算一个员工的不同指标对应的总分数,由于每个员工对应的指标可能不一样,多少可能不一样 ,因此才想到用数组形势存储值.
c#过程的定义:
 public void ceshishuzu()
        {
            int i;
            OracleCommand oracmd = new OracleCommand();
            OracleConnection conn = new OracleConnection(ConStr);
            oracmd.Connection = conn;
            oracmd.CommandText = "jxzlpj.ceshi";     
           oracmd.CommandType = CommandType.StoredProcedure;
            oracmd.Parameters.Add("reccount",OracleType.Int16).Direction=ParameterDirection.Output;
//输出值reccount
            oracmd.Parameters.Add("v_arr", OracleType.?).Direction = ParameterDirection.Output;
//c#中的 oracletype没有table这个类型,我应该如何得到oracle存储过程中v_arr out arr的值?
          }
请指点,谢谢!

解决方案 »

  1.   

    储存过程中一般都是用游标来输出记录集 string cmdText = "whms_inven.get_inven_diff";
                DataTable dt = new DataTable("Difference");            OracleParameter[] parameters = new OracleParameter[2];
                parameters[0] = new OracleParameter("p_bill_no", OracleType.Number);
                parameters[0].Value = checkBillNo;            parameters[1] = new OracleParameter("p_cursor", OracleType.Cursor);  //输出参数
                parameters[1].Direction = ParameterDirection.Output;//把参数放入command.parameters中
                
                return dt;
      

  2.   

    public static int FillDataTable(string cmdText, CommandType cmdType, DataTable dataTable, OracleParameter[] cmdParms)
            { int result;OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand cmd = new OracleCommand();
                OracleConnection conn = _getOracleConnection();cmd.Connection = conn;
                cmd.CommandText = cmdText;
                cmd.CommandType = cmdType;            if (cmdParms != null)
                {
                    foreach (OracleParameter parm in cmdParms)
                    {
                        cmd.Parameters.Add(parm);
                    }
                }
    result=adapter.Fill(dataTable);  //dataTable就是返回的记录集变量
     return result;
            }
    //cmdParms 参数就是上面定义的parameters 
    //dataTable 参数就是上面定义的dt