我有一个table其中有一个列其数值全是用','隔开的,请问我如何能把他们一个个的读出来阿?
例如:
     one,two,three
分别得到他们的值

解决方案 »

  1.   

    select replace(列值,',',chr(13)) from dual;SQL> select replace('one,two,three',',',chr(13)) from dual;REPLACE('ONE,TWO,THREE',',',CH
    ------------------------------
    one
    two
    three
      

  2.   

    用instr 和 substr 結合循環一個一個讀出來
      

  3.   

    create or replace procedure split(msg varchar2) is
      i pls_integer;  
      str varchar2(100);
      temp varchar2(300);
    begin
      temp:=msg;
      
      loop
        i:=instr(temp,',',1,1);
        exit when i=0;
        
        str:=trim(substr(temp,1,i-1));
        temp:=trim(substr(temp,i+1));
        
        dbms_output.put_line(str);
      end loop;  dbms_output.put_line(temp);
    end;