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

时间:2015-06-26 18:40:28

标签: asp.net vb.net stored-procedures oracle10g runtime-error

我收到以下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

我读过这个错误并且人们说如果你将不同的值类型传递给存储过程类型可能会出现此错误,但对我来说似乎并非如此。

enter image description here

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

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;

1 个答案:

答案 0 :(得分:0)

更新已解决的问题:

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;