存储过程里面有声明 sqlscript这个varchar2(2000)变量, hname hcode harttypeid这几个是传进来的参数,有可能为空 harttypeid是number 其他两个是varchar2类型报 
ORA-06502: PL/SQL: 数字或值错误 只要删掉 where 后面的条件就没问题了,大家帮忙看看,谢谢,搞了一天了,郁闷呀.sqlscript:='select a.id as id,t.name as arttypename,a.name as name,a.code as code,a.spec as spec,a.minstock as minstock,a.maxstock as maxstock,
u.name as inunitname,un.name as outunitname,a.unitconversion as unitconversion,a.content as content,a.release as release,un.id as outunitid
from article_article_data a
inner join article_units_data u on a.inwarehouseunitid=u.id
inner join article_units_data un on a.outwarehouseunitid =un.id
inner join article_article_type_data t on (t.id=a.arttypeid)
where nvl2('|| hname ||',a.name,1) like nvl('||'%'|| hname ||'%'||',''1'') 
and nvl2('|| hcode ||',a.code,1) like nvl('||'%'||hcode ||'%'||',''1'') 
and nvl2('|| harttypeid ||',a.arttypeid,1)=nvl('|| harttypeid ||',''1'');
order by a.id';

解决方案 »

  1.   

    where nvl2('|| hname ||',a.name,1) like nvl('||'%'|| hname ||'%'||',''1'') 
    and nvl2('|| hcode ||',a.code,1) like nvl('||'%'||hcode ||'%'||',''1'') 
    and nvl2('|| harttypeid ||',a.arttypeid,1)=nvl('|| harttypeid ||',''1''); 
    换成
    where nvl2('''|| hname ||''',a.name,1) like nvl('||'%'|| hname ||'%'||',''1'') 
    and nvl2('''|| hcode ||''',a.code,1) like nvl('||'%'||hcode ||'%'||',''1'') 
    and nvl2('''|| harttypeid ||''',a.arttypeid,1)=nvl('''|| harttypeid ||''',''1''); 
      

  2.   

    try
    where nvl2('''|| hname ||''',a.name,1) like nvl('''||'%'|| hname ||'%'||''',''1'') 
    and nvl2('''|| hcode ||''',a.code,1) like nvl('''||'%'||hcode ||'%'||''',''1'') 
    and nvl2('''|| harttypeid ||''',a.arttypeid,1)=nvl('''|| harttypeid ||''',''1'')
      

  3.   

    try,我测试了下,发现连接的语句,%前后有缺少引号的现象
    nvl2('|| hname ||',a.name,1) like nvl('||'''%''||'|| hname ||'||''%'''||',''1'') 
    and nvl2('|| hcode ||',a.code,1) like nvl('||'''%''||'||hcode ||'||''%'''||',''1'') 
    and nvl2('|| harttypeid ||',a.arttypeid,1)=nvl('|| harttypeid ||',''1''); 
      

  4.   

    to 2,3 L换成sqlscript:='select a.id as id,t.name as arttypename,a.name as name,a.code as code,a.spec as spec,a.minstock as minstock,a.maxstock as maxstock,
    u.name as inunitname,un.name as outunitname,a.unitconversion as unitconversion,a.content as content,a.release as release,un.id as outunitid
    from article_article_data a
    inner join article_units_data u on a.inwarehouseunitid=u.id
    inner join article_units_data un on a.outwarehouseunitid =un.id
    inner join article_article_type_data t on (t.id=a.arttypeid)
    where nvl2('''|| hname ||''',a.name,1) like nvl('''||'%'|| hname ||'%'||''',''1'') 
    and nvl2('''|| hcode ||''',a.code,1) like nvl('''||'%'||hcode ||'%'||''',''1'') 
    and nvl2('''|| harttypeid ||''',a.arttypeid,1)=nvl('''|| harttypeid ||''',1)
    order by a.id';
    还是一样的错误最后一行把1两个单引号引起来也没用
    大家帮帮忙了.
      

  5.   

    你这个最好把sqlscript的内容message出来看看能清楚点,八成是引号的问题
      

  6.   

    我where后条件只留下 nvl2('''|| hname ||''',a.name,1) like 1                  或者留下                nvl2('|| hname ||',a.name,1) like 1   两种都不行,难道是我传过来的值有问题?
      

  7.   

    nvl2('''|| hname ||''',a.name,1) like ''1''
    只留下这个试试  
      

  8.   

    message   出来不了, 直接就出错了,出错这句就打不出来,除非改成 nvl2('''',a.name,1) like 1   这样才出的来,但是出来没用,晕了.一传值就不行了.
      

  9.   


    a开头的是 in值    h开头的是定义的变量    不行,
    我在上面
    ----判断条件,如果为0或空则不给值
    if(aarttypeid<>0) then
    harttypeid:=aarttypeid;
    end if;
    if(acode is not null) then
    hcode:=acode;
    end if;
    if(aname is not null) then
    hname:=aname;
    end if;
      

  10.   

    不行就只有在java里面拼字符串控制了,郁闷,搞太久了.
      

  11.   

    nvl2('|| hname ||',a.name,1) like nvl('||'''%''||'|| hname ||'||''%'''||',''1'') 
    and nvl2('|| hcode ||',a.code,1) like nvl('||'''%''||'||hcode ||'||''%'''||',''1'') 
    and nvl2('|| harttypeid ||',a.arttypeid,1)=nvl('|| harttypeid ||',''1''); 
      

  12.   

    在试试这个
    sqlscript:='select a.id as id,t.name as arttypename,a.name as name,a.code as code,a.spec as spec,a.minstock as minstock,a.maxstock as maxstock, 
    u.name as inunitname,un.name as outunitname,a.unitconversion as unitconversion,a.content as content,a.release as release,un.id as outunitid 
    from article_article_data a 
    inner join article_units_data u on a.inwarehouseunitid=u.id 
    inner join article_units_data un on a.outwarehouseunitid =un.id 
    inner join article_article_type_data t on (t.id=a.arttypeid) 
    where nvl2('''|| hname ||''',a.name,''1'') like nvl('''||'%'|| hname ||'%'||''',''1'') 
    and nvl2('''|| hcode ||''',a.code,''1'') like nvl('''||'%'||hcode ||'%'||''',''1'') 
    and nvl2('''|| harttypeid ||''',a.arttypeid,''1'')=nvl('''|| harttypeid ||''',''1''); 
    order by a.id';