从SP(Oracle数据库)获取数据时出现问题

问题描述:

大家好,



由于我是新手,我在oracle DB中执行存储过程时遇到了一些问题。这是SP,它将记录作为输出参数,类型为%rowtype,l_serno为输入参数,类型为Number。



Hi All,

As I am new to this, I am facing some issue in executing stored procedure in oracle DB. Here is the SP which gives record as output parameter which is of type %rowtype and l_serno as input parameter which is of type Number.

Create OR Replace procedure get_product(l_serno in product.serno%type,record out product%rowtype)
is

begin

select * into record from product where serno=l_serno;

end get_product;









使用C#,我试图从SP获取数据并在gridview上显示它。







Using C#, I am trying to fetch the data from the SP and show it on the gridview.

OracleCommand cmd = new OracleCommand("get_product", Conn);
                cmd.CommandType = CommandType.StoredProcedure;
                Conn.Open();
                OracleParameter input = cmd.Parameters.Add("V_SERNO", OracleType.Number);
                OracleParameter output = cmd.Parameters.Add("ITEMS_CURSOR", OracleType.Cursor);
                input.Direction = ParameterDirection.Input;
                output.Direction = ParameterDirection.ReturnValue;
                input.Value = 2;
                OracleDataReader rd = cmd.ExecuteReader();
                DataTable dt = new DataTable();
                dt.Load(rd);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                Conn.Close();
<pre/>
Here I am getting error as 

<pre lang="vb">ORA-06550: line 1, column 24:

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

ORA-06550: line 1, column 7:







请让我知道我在这里做错了什么。

先谢谢。




Please let me know what is the wrong I am doing here.
Thanks in Advance.





改变这个...



为什么不提及l_serno作为整数而不是product.serno%​​type?




希望这会对你有所帮助。





干杯
Hi,

Change this...

Why don't you mention l_serno as integer instead of product.serno%type?


Hope this will help you.


Cheers