一个是SELECT lpad(FORWARDER_ID_SEQ.nextval,7,'0') from dual这个SQL(产生个字符串)还有个是
select distinct STATE_SID from ALL_ORG_VIEW where BRANCH_SID =?我想把这两个查询出来的结果拼接
要怎么做ALL_ORG_VIEW是视图谢谢!!

解决方案 »

  1.   

    请写下具体的SQL
    我用||写了几个不行
      

  2.   


    给你个例子SQL> select
      2  ((select lpad('adfdfdfdfd',7,'0') from dual)||
      3  (select substr('1234',1,3) from dual)) from dual
      4  ;
     
    ((SELECTLPAD('ADFDFDFDFD',7,'0
    ------------------------------
    adfdfdf123
      

  3.   

     14:31:47  [SELECT - 0 row(s), 0.000 secs]  [Error Code: 2287, SQL State: 42000]  ORA-02287: sequence number not allowed here
    ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]
    SQL是
    select
    (select distinct STATE_SID from ALL_ORG_VIEW where BRANCH_SID ='898')||
    (SELECT lpad(FORWARDER_ID_SEQ.nextval,7,'0') from dual) from dual
      

  4.   

    SELECT lpad(FORWARDER_ID_SEQ.nextval,7,'0') from dual
    union all
    elect distinct STATE_SID from ALL_ORG_VIEW where BRANCH_SID =? 
      

  5.   

    SELECT lpad(FORWARDER_ID_SEQ.nextval,7,'0') from dual 
    union all 
    select distinct STATE_SID from ALL_ORG_VIEW where BRANCH_SID ='898'错误 14:40:04  [SELECT - 0 row(s), 0.000 secs]  [Error Code: 2287, SQL State: 42000]  ORA-02287: sequence number not allowed here
    ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]
      

  6.   

    SQL> select
      2  ((select lpad('adfdfdfdfd',7,'0') from dual)||
      3  (select substr('1234',1,3) from dual)) from dual
      4  ;
     
    ((SELECTLPAD('ADFDFDFDFD',7,'0
    ------------------------------
    adfdfdf123
    这种的可以,但是加上序列号是不行的 ora-02287:此处不允许序列号
      

  7.   

    lz要序列号是用来干嘛呢?如果不用序列号的话是可以处理的,下面有个demoselect vhcl_maintenance_id||(lpad(rownum,7,'0')) from (select distinct vhcl_maintenance_id,rownum from vhcl_maintenance where vhcl_no like '%21279%');
      

  8.   

    就是sequences不可以加?
    不会吧????你确定?
      

  9.   

    如果简单的用sql来拼接字符串我是可以做的
    但是必须要调用个sequences,因为要与查询出来的sequences拼接在一起
      

  10.   

    上面我写的那个demo就是把他们的后7位全部是连接在一起的了
    你可以试下
      

  11.   

    dengjingheng[color=#FF0000][/color]
     这位朋友可能没理解我的意思。或者我没理解您的意思。
    like '%21279%'。。这个模糊查询干嘛呢?
      

  12.   

    select t.empno,  lpad(seq_test.nextval, 7, '0') 
      from (select distinct empno from emp ) t上面这个语句可以,但不知道是不是你想要的
      

  13.   

    select lpad(FORWARDER_ID_SEQ.nextval,7,'0') || a.state_sid
      from ( select distinct STATE_SID from ALL_ORG_VIEW where BRANCH_SID =?) a;