Oracle 存储过程 PLS-00306:参数数量或类型错误

Oracle Stored Procedure PLS-00306: wrong number or types of arguments

我收到以下 oracle 错误:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERT_CATEGORY'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

我仔细阅读了这个错误,人们说如果你将不同的值类型传递给存储过程类型可能会出现这个错误,但对我来说似乎不是这种情况。

我的大部分编码与我所拥有的几乎相同(并且它们有效)。唯一不同的是我也使用布尔值,所以我不确定这是否也是导致问题的原因。

Protected Sub BtnNew_Click(sender As Object, e As EventArgs) Handles BtnNew.Click
    Dim conn As OleDbConnection = New OleDbConnection("Provider=""*******"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)

    If Page.IsValid Then

        If CatText.Text <> "" Then


            Dim ClassifiedStr As New OleDbCommand

            ClassifiedStr.CommandType = CommandType.StoredProcedure
            'name of stored procedure = 'insert_category'
            ClassifiedStr.CommandText = "insert_category"
            ClassifiedStr.Connection = conn

            'Must be organized based on Stored Procedure
            ClassifiedStr.Parameters.Add("val_category", OleDbType.VarChar, 40).Value = CatText.Text
            conn.Open()

            'Makes sure the Category doesn't already exist****************
            Dim myParm As OleDbParameter = ClassifiedStr.Parameters.Add("val_newcat", OleDbType.Boolean)
            myParm.Direction = ParameterDirection.Output

            ClassifiedStr.ExecuteNonQuery()
            'myParm needs Execute
            Dim standardid As Integer = myParm.Value
            '***********************************************

            If standardid = False Then

                conn.Close()

                Response.Write("<script language=""javascript"">alert('Thanks! Record Has Been Added.');</script>")
                Response.Redirect("DisplayCategories.aspx")
            Else
                Response.Write("<script language=""javascript"">alert('Sorry! Record Already Exist.');</script>")
                Exit Sub
            End If

        Else
            Response.Write("<script language=""javascript"">alert('You must insert a record.');</script>")
            Exit Sub
        End If

    End If

End Sub

存储过程

CREATE OR REPLACE PROCEDURE insert_category
(val_category        TABLENAME.Category%type, 
 val_newcat out boolean) 

as num_catid number;  

begin   

select category_seq.nextval into num_catid from dual;   

  INSERT INTO TABLENAME  
   (select num_catid, val_category from TABLENAME WHERE Category != val_Category);  

commit; 

  val_newcat := SQL%FOUND; 

end;

更新解决的问题:

Dim ClassifiedStr As New OleDbCommand

ClassifiedStr.CommandType = CommandType.StoredProcedure
'name of stored procedure = 'insert_category'
ClassifiedStr.CommandText = "insert_category"
ClassifiedStr.Connection = conn

'Must be organized based on Stored Procedure
ClassifiedStr.Parameters.Add("val_category", OleDbType.VarChar, 40).Value = CatText.Text
conn.Open()

'Makes sure the Category doesn't already exist
Dim myParm As OleDbParameter = ClassifiedStr.Parameters.Add("val_newcat", OleDbType.VarChar, 10)
myParm.Direction = ParameterDirection.Output

ClassifiedStr.ExecuteNonQuery()
'myParm needs Execute before declared

Dim standardid As String = myParm.Value

'***********************************************

If standardid = "TRUE" Then

    conn.Close()
    etc....

存储过程:

(val_category        t_category.Category%type,     
val_newcat out varchar2)     

as num_catid number;      

begin       

select newCategory_seq.nextval into num_catid from dual;         

INSERT INTO TABLENAME      
select num_catid, val_category from dual WHERE not exists (select * from TABLENAME where Category = val_Category);      

val_newcat := case SQL%FOUND when TRUE then 'TRUE' else 'FALSE' end;    

commit;     

end;