SQL过程删除系统权限

时间:2013-02-11 20:45:40

标签: sql oracle plsql

我正在尝试创建一个从某个用户删除系统权限的过程。当我编译我的代码时,我得到“编译错误”

create or replace procedure deactivate_user 
(
p_username in varchar2
)
as
l_username varchar2(30):=upper(p_username);
cnmd varchar2(50);
begin
    for rec (select privilege, admin_option from dba_sys_privs
            where grantee = l_username) loop
            cnmd := 'REVOKE '||rec.privilege||' from '||l_username;
execute immediate cnmd;
end loop;
end;
/

1 个答案:

答案 0 :(得分:1)

您在IN声明中遗漏了FOR;它应该是:

FOR rec IN (SELECT privilege, admin_option FROM dba_sys_privs
            WHERE grantee = l_username) LOOP

请参阅http://docs.oracle.com/cd/E11882_01/appdev.112/e17126/static.htm#CIHCGJAD