title: How to delete sequences and procedures during logoff trigger?
body: <p>Could you please help me in a unique situation I am in. I am receiving &quot;ORA-30511: invalid DDL operation in system triggers&quot; when dropping sequences and procedures during logoff trigger.</p>
  <p>I need to delete tables, sequences and procedures of users before logoff event happens. I am writing the table details in DB_OBJECTS table upon create using a separate trigger. Below is my logoff trigger - could you please help me where I am doing wrong. Dropping tables is working fine in the below code. Only Dropping sequences and procedures is giving me &quot;ORA-30511: invalid DDL operation in system triggers&quot; error.</p>
  <pre><code>CREATE OR REPLACE TRIGGER DELETE_BEFORE_LOGOFF
    BEFORE LOGOFF ON DATABASE
  DECLARE
    USER_ID NUMBER := SYS_CONTEXT('USERENV', 'SESSIONID');
  BEGIN
    FOR O IN (SELECT USER, OBJECT_NAME, OBJECT_TYPE
                  FROM DB_OBJECTS WHERE SID = USER_ID
                  AND USERNAME = USER AND SYSDATE &gt; CREATED_DTTM) LOOP
            IF O.OBJECT_TYPE = 'TABLE' THEN
                EXECUTE IMMEDIATE 'DROP TABLE ' || O.USER || '.' || O.OBJECT_NAME || ' CASCADE CONSTRAINTS';
            ELSIF O.OBJECT_TYPE = 'SEQUENCE' THEN
                EXECUTE IMMEDIATE 'DROP SEQUENCE ' || O.USER || '.' || O.OBJECT_NAME;
            ELSIF O.OBJECT_TYPE = 'PROCEDURE' THEN
                EXECUTE IMMEDIATE 'DROP PROCEDURE ' || O.USER || '.' || O.OBJECT_NAME;
            END IF;
    END LOOP;
    EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
  END;
  /
  </code></pre>