通过PDB进行PL / SQL循环

时间:2019-01-22 14:53:57

标签: oracle plsql dbms-output

我正在尝试编写一个PL / SQL脚本来遍历所有可插拔数据库,执行任务并产生输出。下面的代码是我到目前为止所做的。我不确定发生了什么问题,但是我遇到的错误是 PLS-00306:调用“ PUT_LINE”时参数的数量或类型错误 我不知道为什么。谁能帮忙吗?

declare
type names_t is table of v$pdbs.name%type;
names names_t;
--vname names_t;
type open_modes_t is table of v$pdbs.open_mode%type;
open_modes open_modes_t;
type privilege_user_t is table of dba_sys_privs.privilege%type;
privilege_user privilege_user_t;
begin
        select name, open_mode
        bulk collect
        into names, open_modes
        from v$pdbs
        where name not in ('PDB$SEED' , 'DCPDB01');
                for j in 1 .. names.count()
                loop
                if open_modes (j) <> 'MOUNTED'
                then
                execute immediate 'alter session set container= "' || names (j) || '"';
                end if;
                --select name bulk collect into vname from v$pdbs;
                select grantee bulk collect into privilege_user from dba_sys_privs
                where (privilege like '%ANY%' or privilege ='DBA') and grantee like 'U%'
                group by  grantee, privilege
                order by grantee;
                DBMS_OUTPUT.put_line(privilege_user);
        end loop;
end;
/

1 个答案:

答案 0 :(得分:1)

DBMS_OUTPUT.put_line()需要一个参数字符串。您正在向它传递dba_sys_privs.privilege%type的表的类型。