日期:2014-05-17  浏览次数:20853 次

一个sql语句,请帮看看
select t4.orgid,t4.orgname,t2.paper_name,t1.object_id,t.name, klrms_get_dictname_by_dictid(t.type) type,t.method_summary,decode(t1.hege_flag,1,'合格',0,'不合格') qualified
  from t_klrms_auditpoint t,
  t_kams_applay_auditpoint t1,
  t_kams_work_paper t2,t_kams_project_applay t3,t_krms_org t4 
  where t.object_id=t1.auditpoint_id
  and t1.applay_id in (select p.object_id from t_kams_project_applay p where p.project_main_id=4522)
  and t2.object_id=t1.template_id 
  and t3.auditer=t4.orgid
  and t1.applay_id=t3.object_id;
 这条语句,我在pl/sql执行的时候报“无效数字”的错误,这一句“select p.object_id from t_kams_project_applay p where p.project_main_id=4522”查出来,应该是4523,4524,我如果直接把in后面的括号里换成4523,4524就正确,这是怎么回事呢

------解决方案--------------------
p.project_main_id 是什么数据类型
是字符串的话
改为右边加''
p.project_main_id='4522'
------解决方案--------------------
最好把表结构和数据告诉一下,从代码本身看不出问题所在
------解决方案--------------------
我如果直接把in后面的括号里换成4523,4524就正确
意思是:
把t1.applay_id in (select p.object_id from t_kams_project_applay p where p.project_main_id=4522)
换为t1.applay_id in (4523,4524)

如果是这样就要看t1.applay_id 和p.object_id的数据类型了
------解决方案--------------------
select p.object_id from t_kams_project_applay p where p.project_main_id=4522”查出来的值除了【4523,4524】,有没有空值啊
------解决方案--------------------
请看这一句:t1.applay_id in (select p.object_id from t_kams_project_applay p where p.project_main_id=4522)

是否 t1.applay_id 和t1.applay_id 的数据类型不一致呢?
------解决方案--------------------
你把in里面的SQL单独查下,有可能有空值