简体   繁体   中英

ORA-06550:wrong number or types of arguments in call to 'CHECK_INFO_INS'

Here is my procedure and it works through 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;

Here is my C# code:

        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();

It throws an exception on the executeNonQuery line:

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

I tried to recreate the procedure, but it didn't work. What is wrong with my C# code?

I'm not very familiar with Oracle, but the second parameter in your procedure is named "p_id_check_type" whereas when you add the parameter to the parameters collection, you use the name "p_id_check_categories". Might that be your problem?

Oracle参数名称应以参数列表和SQL语句中的冒号开头,例如:p_currency_rate

Chris is right,

You are using the wrong parameter name in your call to the stored procedure.

So in your call here:

   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);

it should be the same parameter value as found in your stored procedure like so:

    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);

at least whenever i run into this problem:

PLS-00306: wrong number or types of arguments in call to 'CHECK_INFO_INS'

that typically is the reason whenever i run into this problem unless i have the order of parameters wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM