将存储过程放到包里(跟同事学的)

来源:互联网 发布:东华理工行知分院照片 编辑:程序博客网 时间:2024/05/16 05:19
create  or replace package PK_NET_MELT as
  type cur is ref cursor;
  procedure PRO_PMS_NET_MELT(t_cur_sor_ss out cur,stat out NUMBER);
  procedure  PRO_PMS_NET_MELT_NEW;
  end PK_NET_MELT;
 
 
create  or replace package body  PK_NET_MELT AS
        procedure PRO_PMS_NET_MELT(t_cur_sor_ss out cur,stat out NUMBER)
        is
            cursor  cur_sors  is select  pcc.id  id,pcc.teller_code  teller,p.status address_status,pcc.status  salesman_status,em.empno ids_salesman_code,
            (case when em.status='1' then  '0' else '1' end)ids_salesman_status,
            ex.orgstatus  ids_address_status from t_partner_core_config  pcc 
            join t_partner p  on pcc.teller_code=p.teller 
            join empno em on em.empno=pcc.partner_code
            join extorg ex on pcc.teller_code=ex.orgcode;
            v_rowdata  cur_sors%rowtype;--使用游标里的字段类型
            t_count  int;
        begin
              open cur_sors;
              loop
                     fetch cur_sors into v_rowdata;--将游标 
                     exit when cur_sors%notfound;
                     update  t_partner_core_config set
                     address_status=v_rowdata.address_status,
                     ids_salesman_code=v_rowdata.ids_salesman_code,
                     ids_salesman_status=v_rowdata.ids_salesman_status,
                     ids_address_status=v_rowdata.ids_address_status
                     where teller_code=v_rowdata.teller and t_partner_core_config.id=v_rowdata.id;               
                     dbms_output.put_line('sss');
               end loop;
               select  count(*) into t_count from t_partner_core_config where address_status<>ids_address_status  or status<>ids_salesman_status;
               if t_count>0 
                 create  or replace package PK_NET_MELT as
  type cur is ref cursor;
  procedure PRO_PMS_NET_MELT(t_cur_sor_ss out cur,stat out NUMBER);
  procedure  PRO_PMS_NET_MELT_NEW;
  end PK_NET_MELT;
 
 
create  or replace package body  PK_NET_MELT AS
        procedure PRO_PMS_NET_MELT(t_cur_sor_ss out cur,stat out NUMBER)
        is
            cursor  cur_sors  is select  pcc.id  id,pcc.teller_code  teller,p.status address_status,pcc.status  salesman_status,em.empno ids_salesman_code,
            (case when em.status='1' then  '0' else '1' end)ids_salesman_status,
            ex.orgstatus  ids_address_status from t_partner_core_config  pcc 
            join t_partner p  on pcc.teller_code=p.teller 
            join empno em on em.empno=pcc.partner_code
            join extorg ex on pcc.teller_code=ex.orgcode;
            v_rowdata  cur_sors%rowtype;
            t_count  int;
        begin
              open cur_sors;
              loop
                     fetch cur_sors into v_rowdata;--将游标 
                     exit when cur_sors%notfound;
                     update  t_partner_core_config set
                     address_status=v_rowdata.address_status,
                     ids_salesman_code=v_rowdata.ids_salesman_code,
                     ids_salesman_status=v_rowdata.ids_salesman_status,
                     ids_address_status=v_rowdata.ids_address_status
                     where teller_code=v_rowdata.teller and t_partner_core_config.id=v_rowdata.id;               
                     dbms_output.put_line('sss');
               end loop;
               select  count(*) into t_count from t_partner_core_config where address_status<>ids_address_status  or status<>ids_salesman_status;
               if t_count>0
                 then  open  t_cur_sor_ss for select  id,teller_code,status,ids_salesman_code,ids_address_status,address_status,ids_salesman_status  fromt_partner_core_config where address_status<>ids_address_status  or status<>ids_salesman_status;
                 stat:=1;
                end if;
                if t_count=0 then
                  stat:=2;
                end if;
          end  PRO_PMS_NET_MELT;
 
          procedure  PRO_PMS_NET_MELT_NEW
          is
              type v_record is record(
              id  t_partner_core_config.id%type,
              teller  t_partner_core_config.teller_code%type,
               status  t_partner_core_config.status%type,
              ids_salesman_code t_partner_core_config.ids_salesman_code%type,
              ids_address_status t_partner_core_config.ids_address_status%type,
              address_status t_partner_core_config.address_status%type,
              ids_salesman_status t_partner_core_config.ids_salesman_status%type   
             );
               v_rowdata  v_record;
               t_cur_sor_s  cur;
          begin
            
            end PRO_PMS_NET_MELT_NEW;
 
END   PK_NET_MELT;
teller_code,status,ids_salesman_code,ids_address_status,address_status,ids_salesman_status  from t_partner_core_config where address_status<>ids_address_status  or status<>ids_salesman_status;
                 stat:=1;
                end if;
                if t_count=0 then
                  stat:=2;
                end if;
          end  PRO_PMS_NET_MELT;
 
          procedure  PRO_PMS_NET_MELT_NEW
          is
              type v_record is record(
              id  t_partner_core_config.id%type,
              teller  t_partner_core_config.teller_code%type,
               status  t_partner_core_config.status%type,
              ids_salesman_code t_partner_core_config.ids_salesman_code%type,
              ids_address_status t_partner_core_config.ids_address_status%type,
              address_status t_partner_core_config.address_status%type,
              ids_salesman_status t_partner_core_config.ids_salesman_status%type   
             );
               v_rowdata  v_record;
               t_cur_sor_s  cur;
          begin
            
            end PRO_PMS_NET_MELT_NEW;
 
END   PK_NET_MELT;
0 0
原创粉丝点击