这是我的程序,它适用于PL / SQL Developer:
create or replace procedure CHECK_INFO_INS
(
p_id_aircraft IN VARCHAR2,
p_id_check_type IN NUMBER,
p_last_check IN DATE,
p_next_check IN DATE,
p_expectedcost IN NUMBER,
p_id_currency IN NUMBER,
p_currency_rate IN NUMBER
)
is
Rate number;
CurrentDate Date;
catID Checkcategories.Id%type;
begin
select C.ID into catID from CHECKCATEGORIES C WHERE C.NAME='C' and C.CHECKTYPEID = p_id_check_type;
Rate:=round(p_expectedcost/MONTHS_BETWEEN(p_next_check, p_last_check),3)*p_currency_rate;
CurrentDate := SYSDATE;
INSERT INTO CHECK_INFO
(
id_check_info,
id_aircraft,
id_check_categories,
last_check,
next_check,
expectedcost,
is_accumulation_complited,
rate,
id_currency,
current_date,
monthes_between,
CURENCY_RATE
)
values
(
CHECKS_INFO_SEQ.NEXTVAL,
p_id_aircraft,
catID,
p_last_check,
p_next_check,
p_expectedcost,
0,
Rate,
p_id_currency,
CurrentDate,
round(MONTHS_BETWEEN(p_next_check, p_last_check),1),
p_currency_rate
);
commit;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
ROLLBACK;
end CHECK_INFO_INS;
这是我的C#代码:
decimal expectedCost = Decimal.Parse(ExpCostTextBox.Text);
DateTime lastCheck = DateTime.Parse(LastCheckdateTimePicker.Text);
DateTime nextCheck = DateTime.Parse(NextCheckdateTimePicker.Text);
int checkType = int.Parse(ChCmbx.SelectedValue.ToString());
string AirCraft = AirCraftCmbx.SelectedValue.ToString();
int curID = int.Parse(CurrComboBox.SelectedValue.ToString());
decimal curRate = decimal.Parse(CurRateTextBox.Text.Replace('.',','));
con = new OracleConnection(conStr);
con.Open();
cmd = con.CreateCommand();
cmd.BindByName = true;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = schema_name + ".CHECK_INFO_INS";
cmd.Parameters.Add("p_id_aircraft", OracleDbType.NVarchar2, AirCraft, ParameterDirection.Input);
cmd.Parameters.Add("p_id_check_categories", OracleDbType.Int32, checkType, ParameterDirection.Input);
cmd.Parameters.Add("lastCheck", OracleDbType.Date, lastCheck, ParameterDirection.Input);
cmd.Parameters.Add("nextCheck", OracleDbType.Date, nextCheck, ParameterDirection.Input);
cmd.Parameters.Add("p_expectedcost", OracleDbType.Decimal, expectedCost, ParameterDirection.Input);
cmd.Parameters.Add("p_id_currency", OracleDbType.Int32, curID, ParameterDirection.Input);
cmd.Parameters.Add("p_currency_rate", OracleDbType.Decimal, curRate, ParameterDirection.Input);
cmd.ExecuteNonQuery();
它在executeNonQuery行上抛出异常:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'CHECK_INFO_INS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
我尝试重新创建程序,但它没有用。我的C#代码出了什么问题?
答案 0 :(得分:2)
我对Oracle不是很熟悉,但是您程序中的第二个参数名为" p_id_check_type"而当您将参数添加到参数集合时,您使用名称" p_id_check_categories"。可能是你的问题吗?
答案 1 :(得分:0)
Oracle参数名称应以参数列表和SQL语句中的冒号开头,如:p_currency_rate
。
答案 2 :(得分:0)
克里斯是对的,
您在调用存储过程时使用了错误的参数名称。
所以在你的电话中:
cmd.Parameters.Add("p_id_check_categories", OracleDbType.Int32, checkType, ParameterDirection.Input);
cmd.Parameters.Add("lastCheck", OracleDbType.Date, lastCheck, ParameterDirection.Input);
cmd.Parameters.Add("nextCheck", OracleDbType.Date, nextCheck, ParameterDirection.Input);
它应该与存储过程中的参数值相同,如下所示:
cmd.Parameters.Add("p_id_check_type", OracleDbType.Int32, checkType, ParameterDirection.Input);
cmd.Parameters.Add("p_last_check", OracleDbType.Date, lastCheck, ParameterDirection.Input);
cmd.Parameters.Add("p_next_check", OracleDbType.Date, nextCheck, ParameterDirection.Input);
至少每当我遇到这个问题时:
PLS-00306:调用的参数的数量或类型错误 ' CHECK_INFO_INS'
这通常是我遇到此问题的原因,除非我的参数顺序错误。