你的SQL语句有1万多字符啊?。。

解决方案 »

  1.   

    是阿,拼出来的,很多个unit all。。
      

  2.   

    呵呵,你看看Oracle怎么分析你的语句了:)为什么一定要这么写呢??
      

  3.   

    “有很多个union all,”
    =========
    我觉得应该有别的方法可以实现
    这样的语句,显得沉重一些。。
      

  4.   

    应该可以的吧.  varchar2做为变量应该可以存储最长32767个.不过一个sql 写到这么长,恩,也够累的了.
      

  5.   

    不会吧,varchar2最长只能4000多字符吧
      

  6.   

    我再详细描述一下
    我有一张suppliers表,一张products表
    首先我获得所有的suppliers的id,然后按一定逻辑把这些id排序。然后把这些id连接到product的supplierID,字段,获得所有的product,然后拼在一起显示出来。
    例如,suppier的id顺序为 4
                            1
                            2
                            3
    生成的product顺序为: SupplierId    productId
                           4             1
                           4             2
                           ...............
                           1             100
                           1             101
                           ...............
                           2             150
                           2             152
                           ...............
                           3             1000
                           3             1010
      我是这样写的 select * from product where supplierid=4
                   union all
                   select * from product where supplierid=1
                   union all
                   select * from product where supplierid=2
                   union all
                   select * from product where supplierid=3
    有什么更好的方法?
      

  7.   

    哪有你这样写的啊?这样不就可以了?
    select * from product where supplierid between 1 and 4;
      

  8.   

    "首先我获得所有的suppliers的id,然后按一定逻辑把这些id排序”
    =========================================================
    你不妨这样,把这个排序结果存入临时表your_temp,结构如下:
    id supplierid
    1  4
    2  1
    3  2
    4  3
    然后
    select a.* from product a,your_temp b where a.supplierid=b.supplierid order by b.id;
      

  9.   

    一万个字符,太长了,你要优化你的sql了
      

  10.   

    接受ATCG的方法。不过我想问的是,如果真的sql超过varchar2的限制,怎么写?谢谢!
      

  11.   

    那你用 long 好了,长度好几个G呢
    不过确实没有人会写个SQL语句这么长的。。这么长的SQL语句,是没有效率的
    也是很难维护的。个人看法而已。。