求大神帮忙!!!

解决方案 »

  1.   

    存储过程一个参数传入1,2,3,4,5类似的一个字符串,然后要把1   2   3   4   5插入表 
    比如 
    insert   into   table(colum)values(1); 
    insert   into   table(colum)values(2); 
    insert   into   table(colum)values(3); 
    insert   into   table(colum)values(4); 
    insert   into   table(colum)values(5); 请问如何做?是否要用拆分函数,然后用动态sql?--------------------------------
    select sname from test;SNAME
    ---------
    1,2,3,4,5SQL> 
    SQL> select substr(','||t1.sname||',',
      2                instr(','||t1.sname||',',',',1,rn)+1,
      3                instr(','||t1.sname||',',',',1,rn+1)-instr(','||t1.sname||',',',',1,rn)-1) as new_name
      4    from test t1,
      5         (
      6          select rownum rn
      7            from all_objects
      8           where rownum <= 10
      9         )t2
     10   where instr(','||t1.sname||',',',',1,rn+1) > 0;NEW_NAME
    -----------
    1
    2
    3
    4
    5
      

  2.   

    直接instr与substr就可以了instr取需截取的位置,然后在substr
      

  3.   

    利用这个函数就可以了,为什么要自己写呢
    select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,4) from dual 
      

  4.   


    -- 正解!scott@TBWORA> select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,4) from dual;REGEXP
    ------
    e4scott@TBWORA> select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,3) from dual;REGE
    ----
    33scott@TBWORA> select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,2) from dual;REGEXP
    ------
    asdscott@TBWORA> select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,1) from dual;REGEXP
    ------
    123
      

  5.   

    REGEXP_SUBSTR  编译时提示无效的标识符
      

  6.   

    在SQL窗口编译,提示REGEXP_SUBSTR是无效的标识符,求解啊!
    小弟是新手啊,不太懂,谢谢大家了!
      

  7.   


    你 Oracle什么版本?操作时用的什么工具?
      

  8.   

    在PL/SQL Developer中编译的,谢谢,我不太懂!
      

  9.   

    SQL> select REGEXP_SUBSTR('123;asd;33;e4 ','[^;]+',1,4) from dual;
     
    REGEXP_SUBSTR('123;ASD;33;E4',
    ------------------------------
    e4
     
    SQL> 可以的。
      

  10.   

    谢谢,我网上找到一些解释,可能oracle版本不一样吧!REGEXP_LIKE('123123','[0-9]*')  这个是相当于一个boolean表达式啊,当然不能出现在select中了啊,可以在where中出现,
    regexp_substr,regexp_replace,regexp_instr这三个可以出现在select中
    如select * from regtest where regexp_like(a,'\d+'); 你是10g的在plsqldeve中肯定能用
      

  11.   

    另外说下,我的是oracle9i版本,谢谢
      

  12.   

    9i不支持regexp_substr,还是 substr 与 instr 组合使用吧
      

  13.   

       还是写PLSQL来做。很简单的啊。