分割字符

CREATE OR REPLACE TYPE mytable AS TABLE OF varchar2(100)

CREATE OR REPLACE FUNCTION split(p_src VARCHAR2, p_delimiter varchar2)
  RETURN mytable IS
 
  a    mytable := mytable();

  starttimes number := 0;
  sposition1 number := 0;
  sposition2 number := 0;
  srcStr     varchar2(200);
  mysubstr   varchar2(200);

BEGIN
  starttimes := 1;
  sposition1 := 1;
  srcStr     := p_src;
  loop
    sposition2 := instr(srcStr, p_delimiter, 1, starttimes);
    exit when sposition2 = 0;
    mysubstr   := substr(srcStr, sposition1, sposition2 - sposition1);
    sposition1 := sposition2 + 1;
    starttimes := starttimes + 1;
    dbms_output.put_line(mysubstr);
    a.extend;
     a(a.Count) := mysubstr;

  end loop;
  RETURN a;
END;

----


SELECT *
  FROM TABLE(CAST(split('001,--insert into table anyotherthing,', ',') AS
                  mytable));




create table eis_test_local (col_a varchar2(200),col_b varchar2(200),col_c varchar2(200));

select * from eis_test_local;

insert into eis_test_local
  (col_a)
  (SELECT *
     FROM TABLE(CAST(split('001,--insert into table anyotherthing,', ',') AS
                     mytable))
   
   )

 

你可能感兴趣的:(C++,c,C#)