触发启动可插入数据库

时间:2019-04-12 15:18:35

标签: database oracle plsql database-trigger

我正在实现一个触发器,该触发器应手动启动备用容器中的可插拔数据库。这是我的实际代码:

CREATE OR REPLACE TRIGGER managed_startup_pdbs
    AFTER STARTUP ON DATABASE
DECLARE
    pdb_role VARCHAR(40);
    pdb_name VARCHAR(50);
BEGIN
    SELECT open_mode INTO pdb_role FROM v$database;
    IF pdb_role = 'READ ONLY WITH APPLY' THEN
        FOR i IN (SELECT con_name INTO pdb_name FROM dba_pdb_saved_states)
        LOOP
            EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ''|| pdb_name ||'' OPEN READ ONLY;';
        END LOOP;
    END IF;
END;
/

但是它不会启动任何pdb。触发器编译时没有任何错误,我想在execute语句语法错误内或在for循环内可能存在一些问题。

0 个答案:

没有答案