日期:2014-05-17  浏览次数:20955 次

求解C#调用ORACLE(带有输入输出参数)过程中的错误
已知ORACLE过程如下
create or replace procedure WCL_1
/*制作:* 2007-12-22 针对各类业务操作快速过程 */
(
  tiaojian IN VARCHAR2,
  P_YXS_BJH IN CHAR, --第几包件
  P_YXS_BJ IN Integer, --总包件
  P_YXS_XSPC IN VARCHAR2,
  P_YXS_SHDH IN VARCHAR2, -- pbjh,pbj,pxspc,pshdh 为预销售处理的参数
  P_DJCL_KHBH IN VARCHAR2,
  p_DJCL_SPBS IN CHAR, 
  p_DJCL_SL IN NUMBER,
  p_DJCL_CJBZ IN CHAR, -- pspbs,pkhbh,psl,pcjbz 为低价书处理业务参数
  P_MLQH IN VARCHAR2,
  P_MLQH_XSZK IN VARCHAR2,
  P_MLQH_QSSJ IN DATE,
  P_MLQH_ZZSJ IN DATE,
  result OUT NUMBER, -- '2' 成功,'1'失败
  p_nErrCode OUT NUMBER,
  p_vErrText OUT VARCHAR2


IF tiaojian='mlqhzk' THEN --根据目录期号设置折扣
  begin
  insert into wcl_12(spbs,xszk,tm)
  select b.spbs,P_MLQH_XSZK,P_MLQH from jcdcg_dmlb a,bm_jbxxk b where a.dpzbm_fk=b.dpzbm and a.zdmlqh_pk=P_MLQH;
   
  insert into jcdms_zkb_new(bmbh,yxxl,bbbh,bbmc,spbs,sm,qsrq,zzrq,zkl,szr,szsj,syxz,id)
  select '02',b.ywxl,b.bb,b.bb||'|'||c.cbsjc,a.spbs,b.sm,sysdate-10,sysdate-10,a.xszk xszk,'proc',sysdate,'1',WCL_XH.Nextval
  from wcl_12 a,bm_jbxxk b,bm_cbsbmb c
  where a.spbs=b.spbs 
  and b.bb=c.bb
  and trim(a.tm)=P_MLQH;
  end;
  END IF;
 
  Commit;
  result := 2;
  p_nErrCode := 0;
  p_vErrText := '成功';
  return;

EXCEPTION
  --失败数据回滚,显示错误代码!
  WHEN OTHERS THEN
  Rollback;
  result := 1;
  p_nErrCode := SQLCODE;
  p_vErrText := SQLERRM;
  return;

END WCL_1;

我在C# winform中用了以下代码,但是执行过程不成功,后来调试时提示是ORA-06550错误,好像是参数类型与过程中参数不符,现贴上C#中的源码,望各位高手指点一下
  private void button1_Click(object sender, EventArgs e)
  {
  OracleConnection conn = new OracleConnection(Dboperation.connectionstring);
  conn.Open();
  OracleCommand cmd = new OracleCommand("WCL_1", conn);
  cmd.CommandType = System.Data.CommandType.StoredProcedure;

  OracleParameter ptiaojian=new OracleParameter("tiaojian",OracleType.Char);
  OracleParameter p1=new OracleParameter("P_MLQH",OracleType.Char);
  OracleParameter p2=new OracleParameter("P_MLQH_XSZK",OracleType.Char);
  ptiaojian.Value = "mlqhzk";
  p1.Value = "16901096";
  p2.Value = "90";
  ptiaojian.Direction = ParameterDirection.Input;
  p1.Direction = ParameterDirection.Input;
  p2.Direction = ParameterDirection.Input;

  OracleParameter resul = new OracleParameter("result",OracleType.Float,4);
  OracleParameter errtext = new OracleParameter("p_vErrText", OracleType.VarChar,60);
  resul.Direction = ParameterDirection.Output;
  errtext.Direction = ParameterDirection.Output;

  cmd.Parameters.Add(ptiaojian);
  cmd.Parameters.Add(p1);
  cmd.Parameters.Add(p2);

  cmd.Parameters.Add(resul);
  cmd.Parameters.Add(errtext);
  try
  {
  cmd