求助,c#中执行oracle存储过程错误
////////////////////下面为oracle存储过程代码CREATE OR REPLACE PROCEDURE ADDSTUSCORE
(
P_XH IN XS.XH%TYPE,
P_KCM IN KC.KCM%TYPE,
P_CJ IN XS_KC.CJ%TYPE)
AS
V_KCH KC.KCH%TYPE;
V_COUNT number;
V_XF XS_KC.XF%TYPE;
begin
select KC.KCH into V_KCH from KC where KC.KCM=P_KCM;
select KC.XF into V_XF from KC where KC.KCM=P_KCM;
select count(*) into V_COUNT from XS_KC where XS_KC.XH=P_XH and XS_KC.KCH=V_KCH;
if V_COUNT=1 then
update XS_KC set XS_KC.CJ=P_CJ,XS_KC.XF=V_XF where XS_KC.XH=P_XH and XS_KC.KCH=V_KCH;
else
insert into XS_KC values(P_XH,V_KCH,P_CJ,V_XF);
end if;
end;
/
///////////////////////////////在oracle执行此过程能够成功
declare
xh1 Char(8);
kcm1 varchar2(16);
cj1 Number(3);
begin
xh1:='11111111';
kcm1:='数据结构';
cj1:=44;
ADDSTUSCORE(xh1,kcm1,cj1);
end;
/
////////////////////////////////////下面是C#的代码
conn = new OracleConnection(txtConn);
OracleCommand cmd = null;
cmd = conn.CreateCommand();
cmd.CommandText = "ADDSTUSCORE";//存储过程名
cmd.CommandType = CommandType.StoredProcedure;//声明调用存储过程
//存储过程的参数,paramin代表参数名,OracleType.VarChar代表参数类型,20代表参数的大小
OracleParameter xh_in = cmd.Parameters.Add("xh1", OracleType.Char, 8);
xh_in.Direction = ParameterDirection.Input;//代表参数的存储方式
xh_in.Value = textBox16.Text;
OracleParameter kcm_in = cmd.Parameters.Add("kcm1", OracleType.VarChar, 16);
kcm_in.Direction = ParameterDirection.Input;
kcm_in.Value = comboBox1.Text;
OracleParameter cj_in = cmd.Parameters.Add("cj1", OracleType.Number, 3);
cj_in.Direction = ParameterDirection.Input;
cj_in.Value = textBox17.Text;
conn.Open();
//执行存储过程
cmd.ExecuteNonQuery();
conn.Close();
//////////////////////////////执行后出现错误如下:
ORA-06550: 第 1 行, 第 7 列:
PLS-00306: 调用 'ADDSTUSCORE' 时参数个数或类型错误
以数组形式定义参数仍然出现此错误,求助大家,第一次发帖,没有可用分数,不好意思~ --------------------编程问答-------------------- OracleParameter xh_in = cmd.Parameters.Add("xh1", OracleType.Char, 8);
这里的参数名要和存储过程里定义的参数名一样
P_XH IN XS.XH%TYPE,
P_KCM IN KC.KCM%TYPE,
P_CJ IN XS_KC.CJ%TYPE --------------------编程问答-------------------- 将oracle过程改为如下后,C#仍然出现此错误
不过还是谢谢了
CREATE OR REPLACE PROCEDURE ADDSTUSCORE
(
P_XH IN Char,
P_KCM IN varchar2,
P_CJ IN Number)
AS
V_KCH char(3);
V_COUNT Number;
V_XF Number;
begin
select KC.KCH into V_KCH from KC where KC.KCM=P_KCM;
select KC.XF into V_XF from KC where KC.KCM=P_KCM;
select count(*) into V_COUNT from XS_KC where XS_KC.XH=P_XH and XS_KC.KCH=V_KCH;
if V_COUNT=1 then
update XS_KC set XS_KC.CJ=P_CJ,XS_KC.XF=V_XF where XS_KC.XH=P_XH and XS_KC.KCH=V_KCH;
else
insert into XS_KC values(P_XH,V_KCH,P_CJ,V_XF);
end if;
end;
/
补充:.NET技术 , C#