OIM 10g 完全删除一个帐号

How to remove all users whose USR_LOGIN beginning with "T11111" from USR table individually?

 

 

SET SERVEROUTPUT ON SIZE 1000000


DECLARE

   z_usr_login USR.USR_LOGIN%TYPE;
   z_total NUMBER;
   CURSOR c_user IS SELECT USR_LOGIN from USR where USR_LOGIN like 'T11111%' order by USR_LOGIN;

BEGIN

   select count(*) into z_total from USR where USR_LOGIN like 'T11111%';
   
   IF z_total != 0 THEN
      DBMS_OUTPUT.PUT_LINE('Starting to delete ' || z_total || ' T11111X Users ... ');
      DBMS_OUTPUT.PUT_LINE('----- ----- ----- ----- -----');

      OPEN c_user;

      FOR counter in 1..z_total
         LOOP

            FETCH c_user INTO z_usr_login;
            delete from oiu where usr_key in (select usr_key from usr where usr_login = z_usr_login);
            delete from oio where orc_key in (select orc_key from orc,usr where orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from osi where orc_key in (select orc_key from orc,usr where orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from rcd where rce_key in (select rce_key from rce,orc,usr where rce.orc_key = orc.orc_key and orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from rch where rce_key in (select rce_key from rce,orc,usr where rce.orc_key = orc.orc_key and orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from rcu where rce_key in (select rce_key from rce,orc,usr where rce.orc_key = orc.orc_key and orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from rcb where rce_key in (select rce_key from rce,orc,usr where rce.orc_key = orc.orc_key and orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from rce where orc_key in (select orc_key from orc,usr where orc.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from orc where usr_key in (select usr_key from usr where usr_login = z_usr_login);
            delete from upd where upp_key in (select upp_key from upp,usr where upp.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from upp where usr_key in (select usr_key from usr where usr_login = z_usr_login);
            delete from usg where usr_key in (select usr_key from usr where usr_login = z_usr_login);
            delete from uhd where uph_key in (select uph_key from uph,usr where uph.usr_key = usr.usr_key and usr_login = z_usr_login);
            delete from uph where usr_key in (select usr_key from usr where usr_login = z_usr_login);
            delete from usr where usr_login = z_usr_login;
            commit;

         END LOOP;
      CLOSE c_user;

      DBMS_OUTPUT.PUT_LINE('Deletion of T11111X Users is complete. ');
   
   ELSE
         DBMS_OUTPUT.PUT_LINE('NO T11111X User is found. ');

   END IF;
   
END;
/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值