<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

 

oracle视频教程create or replace procedure p_separate(in_org_list in varchar2)

is

v_sql varchar2(3000);

v_new_pos integer;

v_new_sql varchar2(3000);

v_flag integer;

begin

  v_sql:=in_org_list;

  -- 分几种情况:

  --1, 仅一个公司

  --2, 多个公司,但以逗号分隔

  -- 表明至少有 >=2 个公司

  v_new_sql:='';

  -- a,b,c

  if instr(v_sql,',',1)>0 then

     

    while(instr(v_sql,',',1)>0) loop

     v_new_sql:=v_new_sql||''''||substr(v_sql,1,instr(v_sql,',',1)-1)||''''||',';

     v_new_pos:=instr(v_sql,',',v_pos)+1;

     v_sql:=substr(v_sql,v_new_pos);

    end loop;

    v_flag:=1;

  else

    -- 表明仅一个公司

    v_new_sql:=''''||v_sql||'''';

    v_flag:=0;

  end if;