首页 新闻 会员 周边 捐助

asp.ney调用orcle 存储过程出错

0
悬赏园豆:50 [已关闭问题] 关闭于 2010-03-17 16:21

模糊查询一个字段可以多个就出错 在pl/sql 中运行测试正常 而asp.net 就出错

错误为:

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

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

存储过程为:

 

CREATE OR REPLACE PROCEDURE CITY_SEARCH
(
CUR OUT SYS_REFCURSOR,
PAR_NID varchar2,
PAR_NAMES varchar2,
PAR_SPELL varchar2
)
IS
  INSR NUMBER;
BEGIN
  INSR:=LENGTH(PAR_NID);
    IF INSR>0 THEN
       OPEN CUR FOR SELECT * FROM CITY 
       WHERE (SUBSTR(NID,0,INSR)=PAR_NID)AND 
       (NAMES LIKE '%' || PAR_NAMES || '%' OR PAR_NAMES IS NULL) 
       AND (SPELL LIKE '%' || PAR_SPELL || '%' OR PAR_SPELL IS NULL);
   ELSE
       OPEN CUR FOR SELECT * FROM CITY 
       WHERE (NAMES LIKE '%' || PAR_NAMES || '%' OR PAR_NAMES IS NULL)
       AND (SPELL LIKE '%' || PAR_SPELL || '%' OR PAR_SPELL IS NULL);
   END IF;
END ;
CREATE OR REPLACE PROCEDURE CITY_SEARCH(

CUR OUT SYS_REFCURSOR,

PAR_NID varchar2,

PAR_NAMES varchar2,

PAR_SPELL varchar2

)

IS

  INSR NUMBER;

BEGIN

INSR:=LENGTH(PAR_NID);

    IF INSR>0 THEN

       OPEN CUR FOR SELECT * FROM CITY 

       WHERE (SUBSTR(NID,0,INSR)=PAR_NID)AND 

       (NAMES LIKE '%' || PAR_NAMES || '%' OR PAR_NAMES IS NULL) 

       AND (SPELL LIKE '%' || PAR_SPELL || '%' OR PAR_SPELL IS NULL);

   ELSE

       OPEN CUR FOR SELECT * FROM CITY 

       WHERE (NAMES LIKE '%' || PAR_NAMES || '%' OR PAR_NAMES IS NULL)

       AND (SPELL LIKE '%' || PAR_SPELL || '%' OR PAR_SPELL IS NULL);

   END IF;

end;

调用为:

public static DataTable UP_city_GetList(city model)

    {

        OleDbParameter[] parm ={

               oledate.CreateInParam("Par_NID",OleDbType.VarChar,100,model.nid),

               oledate.CreateInParam("Par_NAMES",OleDbType.VarChar,30,model.name),

               oledate.CreateInParam("Par_SPELL",OleDbType.VarChar,20,model.spell)};

        return oledate.ExecuteTable(CommandType.StoredProcedure, "CITY_Search", parm);

    }

页面显示:

        city model = new city();

        model.name = "";

        model.spell = "";

        model.nid = "";

        GridView1.DataSource = city.UP_city_GetList(model);

        GridView1.DataBind();


林雨....的主页 林雨.... | 初学一级 | 园豆:116
提问于:2010-03-17 10:01
< > 字节跳动旗下AI助手豆包
分享
所有回答(1)
0

PLS-00306这个错误号是指:调用存储过程时参数数量或类型错误。你的存储过程有4个参数,包括一个隐式游标,但是调用的时候只输入了三个参数,自然会报这个错误。参考:
代码
public static DataTable UP_city_GetList(city model)

{

OleDbParameter[] parm
={

oledate.CreateInParam(
"CUR",OleDbType.Cursor),

oledate.CreateInParam(
"Par_NID",OleDbType.VarChar,100,model.nid),

oledate.CreateInParam(
"Par_NAMES",OleDbType.VarChar,30,model.name),

oledate.CreateInParam(
"Par_SPELL",OleDbType.VarChar,20,model.spell)};

parm[
0].Direction = ParameterDirection.Output;

return oledate.ExecuteTable(CommandType.StoredProcedure, "CITY_Search", parm);

}

 


麒麟.NET | 园豆:3614 (老鸟四级) | 2010-03-17 10:29
OleDbType 找不到的游标类型,怎么给它定义
支持(0) 反对(0) 林雨.... | 园豆:116 (初学一级) | 2010-03-17 10:41
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册
Top