这是我在做数据库查询时候的SQL语句。
select tb.sitemcd,i.item,tb.qt from (select distinct(b.sitemcd),decode(b.sitemcd,a.sitemcd,(b.qt-a.qt),b.qt) qt from (select sitemcd,sum(qt) qt from item_bom where mitemcd= 'E27EI8000000BM03' and factcd='00062' group by sitemcd) a, (select sitemcd,sum(qt) qt from item_bom where mitemcd='E272EA000000BM03' and factcd='00062' group by sitemcd) b where (b.sitemcd=a.sitemcd and b.qt>a.qt) or b.sitemcd not in (select distinct(sitemcd) from item_bom where mitemcd='E27EI8000000BM03' and factcd='00062' )) tb,item i where tb.sitemcd=i.itemcd(+) order by tb.sitemcd运行程序:
Statement stmt = null;
stmt = this.conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);但是System.out.println(rs.next());显示的是false.
我把SQL占到sql plus中可以找到数据!什么原因呢?

解决方案 »

  1.   

    你的sql string是什么?找不到,太乱了!
      

  2.   

    楼主你就是这么写sql的啊,自己看了都晕吧.
      

  3.   

    大家先别讨论为什么这么写,先帮忙为什么会这样?
    是SQL语句太长了吗?
      

  4.   

    他们说的是你的SQL写的太懒太难看了。嘿嘿。
    我也有同感。
      

  5.   

    我的SQL语句是不好看,但是我在SQL PLUS下测试没有错误,可以查出数据的!
      

  6.   

    Oh my godness!
    建议楼主把你的SQL语句优化
      

  7.   

    问题解决了,我的数据库驱动连接的数据库搞错了了!
    结贴!
    谢谢大家批评我的SQL语句不好看!哈哈!