日期:2014-05-17  浏览次数:20763 次

存储过程的牛人过来看下!
create or replace procedure sp_check_to_market(
  wf_id_in           in        number,
  form_data_id_in    in        number,
  market_id          in        varchar2
 -- return_code        out       number,
  --return_desc        out       varchar2
 )
as
  type c_array  is table of varchar2(10) index by binary_integer;
  p number default 0;
  idx number default 0;
  strc varchar2(500);
  ca c_array;
  market_id2 varchar(500);
begin

    strc:=market_id;
    loop
        p:=instr(strc,'-',1);
        exit when p=0;
        ca(idx):=substr(strc,1,p-1)||',';
        dbms_output.put_line(ca(idx));
        idx:=idx+1;

        p:=instr(strc,'|',1);
        exit when p=0;
        strc:=substr(strc,p+1,length(strc));
    end loop;
     declare
  cursor indexs
    is
     select status_id   from ecl_request_sheet where request_id in(ca(idx)) and container_type=4 ;
   
     --定义一个游标变量
        c_row indexs%rowtype;begin
         open indexs;
         loop
         fetch indexs into c_row;
         exit when indexs%notfound;
          
        if c_row.status_id<>6 then
        -- return_code:=1;
       --  return_desc:='销售合同未结束';
       dbms_output.put_line('OK');
        else
      --   return_code:=0;
       dbms_output.put_line('NO');
        end if;
       end loop;       --关闭游标
       close indexs;
    end;

 COMMIT;

  EXCEPTION

  WHEN OTHERS THEN
  ROLLBACK;
  RAISE;

END;

请问我这样里有什么问题。。上面是截取数据
类似101532-国外出差审批流程 [ 0|P,106-管理员 ] |101530-国外出差审批流程 [ 0|P,106-管理员 ]
这样两条 我只取它们的ID:101530,101532