CREATING TRIGGER

create trigger DDL_GUARD_cact
before DROP or TRUNCATE or DELETE
on cidcb_cac
begin
raise_application_error( -20001, 'You are not allowed to DROP or TRUNCATE table in this schema. ' );
end;
I am try to build a triger so that no one can delete truncate or delete my table in schema but it is showing me error when i m executing it...
ORA-30506: system triggers cannot be based on tables or views
i think i am wrong in writing this query ...can someone guied me in creating this kind of trigger ...i am a user in oracle not administrator......
so how can show error if someone try to do with my table in my schema like HR
thanks in advance....:)
using oracle 10.2g SE

You cannot define a trigger of system level (drop, truncate) on a table since they are not DML, but DDL. These commands should be defined at schema level.
Please, take a look to the trigger doc
Nicolas.
Re: Trigger ON DELETE or DROP or TRUNCATE
Message was edited by:
N. Gasparotto

Similar Messages

  • Use of "DBA_OBJECTS" in "AFTER CREATE" Trigger

    Hi,
    We would like to store some extra information about our objects we have in the database. To do so we tought of the idea of creating a 'documenting' table containing an object_id that references to the object_id from the view dba_views.
    Now we want to automatically create a new record in our documenting table when a new object is created, in the first stage this should only contain the object_id
    To accomplish this we are using an 'AFTER CREATE' trigger, but when this trigger fires and the code searches for the new object_id in dba_objects, it does not return any records and generates an error. Likely because when the trigger is executed, the view is not yet updated?
    create or replace
    TRIGGER TRG_TEST
    AFTER CREATE ON SCOTT.SCHEMA
    DECLARE
    tmp VARCHAR2(50);
    BEGIN
    dbms_output.put_line(ora_dict_obj_name);
    select object_id
    into tmp
    from dba_objects
    where object_name = ora_dict_obj_name;
    dbms_output.put_line(tmp);
    END;
    Error report:
    ORA-04088: Fout bij uitvoering van trigger 'SCOTT.TRG_TEST'.
    ORA-01403: Geen gegevens gevonden.
    ORA-06512: in regel 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    It's in dutch, so I'll have a go at translating:
    Error report:
    ORA-04088: Exception while executing trigger 'SCOTT.TRG_TEST'.
    ORA-01403: No data found
    ORA-06512: in rule 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    Does anyone have an idea of how I can accomplish what I'm trying to do here.. Or maybe something I'm doing wrong?
    Thanks in advance!
    Davy

    What is "ora_dict_obj_name" defined as?
    Another option might be to setup a DBMS_SCHEDULER job to run the following insert
    firstly though, create the following table ;
    create document_table as (select * from dba_objects where rownum < 1)and then setup a DBMS_SCHEDULER job to run the following:
    begin
      insert into document_table
      (select dbo.*
       from   dba_objects    dbo
             ,document_Table dtb
       where  dbo.Object_ID = dtb.Object_ID(+)
       and    dtb.Object_ID is null);
       commit;
       exception
        when others then
          rollback;
          -- log a message somewhere with the error, i.e. SQLERRM
    end;
    /Note, I specified all columns, but you'll probably specify explicitly which column you require, in which case the CREATE table would change as well.
    Then you won't have a need for any trigger, and can better manage when you want your documentation to be updated.
    Another option might be to use COMMENT, which can be used on tables, views, materialized views, but won't cover all objects
    to the extent you might want.
    SQL> desc emp2
    Name                                                                                                  
    EMPNO                                                                                                 
    JOB                                                                                                   
    START_DATE                                                                                            
    SAL                                                                                                   
    DEPT                                                                                                  
    END_DATE                                                                                              
    SQL> comment on column emp2.sal is 'Existing Salary of employee as paid at most recent month end';

  • Execute create trigger script in a procedure

    Is it possible to create a trigger with pl/sql?
    I have made a procedure thats makes the create or replace trigger statement.
    (when i copy and past the statement the trigger is created succesvol)
    How can i execute the create trigger statement on the end of the procedure?
    Thanks.

    Well, then proceed with dynamic SQL.
    Or, in my opinion much better: produce a SQL script with variables for table name and trigger name.
    Then run this script with the appropriate values every time you have created a table.
    Cheers,
    Guido
    Edited by: Guido on Oct 22, 2008 10:30 AM

  • Need help with create trigger based on more then 1 table and join.

    Hello,
    Here i have 3 tables
    1. Employee
    PERSON_ID
    1
    1
    N
    NUMBER
    None
    ORG_ID
    2
    N
    NUMBER
    Frequency
    LOC_ID
    3
    N
    NUMBER
    Frequency
    JOB_ID
    4
    Y
    NUMBER
    Height Balanced
    FLSA_STATUS_ID
    5
    Y
    NUMBER
    Frequency
    FULL_NAME
    6
    N
    VARCHAR2 (250 Byte)
    Height Balanced
    FIRST_NAME
    7
    N
    VARCHAR2 (20 Byte)
    Height Balanced
    MIDDLE_NAME
    8
    Y
    VARCHAR2 (60 Byte)
    Height Balanced
    LAST_NAME
    9
    N
    VARCHAR2 (40 Byte)
    Height Balanced
    PREFERRED_NAME
    10
    Y
    VARCHAR2 (80 Byte)
    None
    EMAIL
    11
    Y
    VARCHAR2 (250 Byte)
    None
    MAILSTOP
    12
    Y
    VARCHAR2 (100 Byte)
    None
    HIRE_DATE
    13
    N
    DATE
    None
    2. ems_candidate
    EMS_CANDIDATE_ID
    1
    1
    N
    NUMBER
    None
    EMS_JOB_ID
    2
    Y
    NUMBER
    Frequency
    NAME
    3
    N
    VARCHAR2 (255 Byte)
    Frequency
    EMAIL
    4
    Y
    VARCHAR2 (255 Byte)
    None
    TELEPHONE
    5
    Y
    VARCHAR2 (25 Byte)
    None
    EMS_SOURCE_ID
    6
    Y
    NUMBER
    Frequency
    RECEIVED_DATE
    7
    Y
    DATE
    Frequency
    COMMENTS
    8
    Y
    VARCHAR2 (4000 Byte)
    None
    3. employee_resources
    EMP_RES_ID
    1
    1
    N
    NUMBER
    None
    PERSON_ID
    2
    Y
    NUMBER
    Height Balanced
    CANDIDATE_ID
    3
    Y
    NUMBER
    Frequency
    EMP_START_DATE
    4
    Y
    DATE
    None
    CUSTOM_RESOURCE_FLAG
    5
    Y
    NUMBER (1)
    None
    RESOURCE_GROUP_ID
    6
    N
    NUMBER
    Frequency
    RESOURCE_STATUS_ID
    7
    N
    NUMBER
    Frequency
    GROUP_LOC_ID
    8
    N
    NUMBER
    Height Balanced
    ASSIGNED_JIRA
    9
    Y
    VARCHAR2 (250 Byte)
    None
    REVOKED_JIRA
    10
    Y
    VARCHAR2 (250 Byte)
    None
    CREATED_DATE
    11
    Y
    DATE
    SYSDATE
    None
    UPDATED_DATE
    12
    Y
    DATE
    None
    Now i want to create trigger when new record get inserted in employee table wanted to update person_id in employee_resources table.
    So i want to match ems_candidate.name with employee.full_name , ems_candidate.ems_job_id with employee.ems_job_id. And if it matched then update person_id in employee_resources table else through an exception and insert record in temp table.
    If anybody has an idea can u please help me.
    Thanks,
    Gayatri.

    I created below trigger
    CREATE TRIGGER emp_resources_upd_person_id
    AFTER INSERT ON ems.employee
    FOR EACH ROW
    BEGIN
        UPDATE ems.employee_resources
           SET person_id = :new.person_id
         WHERE candidate_id = (SELECT ems_candidate_id  
                                 FROM ems.ems_candidate cand, ems.employee emp
                                WHERE TRIM(UPPER(emp.first_name)) = TRIM(UPPER(SUBSTR (cand.name, 1, INSTR (cand.name, ' ') - 1)))
                                  AND TRIM(UPPER(emp.last_name)) = TRIM(UPPER(SUBSTR (cand.name,INSTR (cand.name, ' ') + 1,DECODE (INSTR (SUBSTR (cand.name, INSTR (cand.name, ' ') + 1), ' '),0,LENGTH (cand.name),(INSTR (SUBSTR (cand.name, INSTR (cand.name, ' ') + 1), ' ') - 1)))))
                                  AND emp.person_id = :new.person_id);
    EXCEPTION
      WHEN OTHERS THEN
        INSERT INTO ems.update_person_id_exception(person_id,first_name,last_name,full_name) VALUES(:new.person_id,:new.first_name,:new.last_name,:new.full_name);
    END;
    Now when i am trying to insert row in ems.employee  table it gives me an error
    ORA-04091
    table string.string is mutating, trigger/function may not see it
    Cause: A trigger (or a user defined plsql function that is referenced in this statement) attempted to look at (or modify) a table that was in the middle of being modified by the statement which fired it.
    Action: Rewrite the trigger (or function) so it does not read that table.
    Can anybody please help me to come out from these error.
    Thanks,
    Gayatri.

  • Please trace what is wrong in TRIGGER script , doesnt create trigger.

    Hi Oracle Gurus,
    Please help me, in finding what is wrong in trigger statement. It doesn not create trigger, instead it displays line numbers..like 1 2 3 4 ....after pressing the enter key,
    I am attaching the full script, where it alters table, then creates new table, the creates sequence..lastly it fails in creating the trigger.
    ==================================================================================
    SQL> ALTER TABLE MOBILE.MOBILE_USER ADD (LAST_LOGIN TIMESTAMP);
    Table altered.
    SQL> CREATE TABLE "MOBILE"."AUDIT_LOG"
    2 3 "AUDIT_LOG_ID" NUMBER(16,0) NOT NULL ENABLE,
    4 "DATE_CREATED" TIMESTAMP (6) NOT NULL ENABLE,
    5 "AUDIT_TYPE" VARCHAR2(20 BYTE) NOT NULL ENABLE,
    6 "AUDIT_DATA" CLOB,
    7 CONSTRAINT "AUDIT_LOG_PK" PRIMARY KEY ("AUDIT_LOG_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "SERVICES_DATA" ENABLE
    8 )
    9 PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
    10 11 12 )
    TABLESPACE "SERVICES_DATA" LOB
    13 14 (
    15 "AUDIT_DATA"
    16 )
    17 STORE AS
    18 (
    19 TABLESPACE "SERVICES_DATA" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    20 ) ;
    Table created.
    SQL> CREATE SEQUENCE "MOBILE"."AUDIT_LOG_SEQ" INCREMENT BY 1 START WITH 1000 CACHE 20 NOCYCLE ;
    Sequence created.
    SQL> create or replace
    TRIGGER "MOBILE"."AUDIT_LOG_TRGR" before
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    SELECT AUDIT_LOG_SEQ.nextval
    INTO :NEW."AUDIT_LOG_ID"
    FROM dual;
    END IF;
    END IF;
    END;

    Ok great..but it gives the same error, we have already checked that AUDIT_LOG does exist.
    Is it checking something else..or it shoud be INSERT INTO instead of INSERT ON.
    Please help.
    create or replace
    TRIGGER "MOBILE"."AUDIT_LOG_TRGR" before
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    SELECT AUDIT_LOG_SEQ.nextval
    INTO :NEW."AUDIT_LOG_ID"
    FROM dual;
    END IF;
    END IF;
    END; /
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    ERROR at line 3:
    ORA-00942: table or view does not exist

  • Create trigger on view belong to different schema of same db

    Hi Guru's,
    I have two different schema in the same DB.
    Example : schema1 and schema2
    I have one view on schema1 and i have grant select to schema2 and create synonym for that view.
    Now i need to create trigger on synonym which created from view in schema1 and insert the data into different table from trigger when insert happen on view.
    first of all , is it possible?
    if its possible then do i need to give create any trigger on view to schema2.
    Or is there any other we can get this done..
    Many thanks.

    Hi,
    user590978 wrote:
    Hi Guru's,
    I have two different schema in the same DB.
    Example : schema1 and schema2
    I have one view on schema1 and i have grant select to schema2 and create synonym for that view.
    Now i need to create trigger on synonym I'm not sure I understand you.
    Triggers operate on tables and views (but I'll just say "table" from now on). It doesn't matter if the statement that caused the trigger to fire used the actual table name or a synonym.
    which created from view in schema1 and insert the data into different table from trigger when insert happen on view.
    first of all , is it possible?I'm not sure I understand you here, either.
    It is possible to have a trigger on a view in schema1, which INSERTs data into a table. That table can be in any schema, just so long as the trigger owner has privilges on INSERT into it.
    if its possible then do i need to give create any trigger on view to schema2.It's very dangerous, and usually a terrible idea, to grant the CREATE ANY privileges to users.
    Schema2 needs the CREATE ANY TRIGGER system privilege only to create a trigger in another schema, such as schema1. There's probably no reason to do that. Let schmea1 create the objects in its own schema.
    Post a test script that shows what you want to do. Include CREATE TABLE, CREATE VIEW, CREATE TRIGGER, CONNECT and INSERT statements, and the results you want (the contents of tables where the trigger INSERTed data). If you don't know how to code something, post the closest thing you can, and explain what you really want to do in that place.

  • Getting error while creating trigger!!

    Hi Guys,
    I am getting the following error while creating trigger in Oracle10g Database in TOAD environment.
    Error: PLS-00306: wrong number or types of arguments in call to '='
    Table details:
    One of the column having BLOB Data type in the table.
    In the trigger, I have compared :old and :new values.
    CREATE OR REPLACE TRIGGER INPL.trigger_new
    AFTER INSERT OR UPDATE OR DELETE
    ON TABLE_NEW REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    action_flag VARCHAR2(1);
    new_image BLOB;
    BEGIN
    IF UPDATING
    THEN
    action_flag := 'U';
    ELSIF DELETING
    THEN
    action_flag := 'D';
    ELSIF INSERTING
    THEN
    action_flag := 'I';
    END IF;
    IF (:NEW.image = :OLD.image)
    THEN
    new_image := '';
    ELSE
    new_image := :NEW.image;
    END IF;
    INSERT INTO TABLE_NEW(action_flag, date_changed,nimage,oimage) values(new_image,:old.image);
    end;
    Any one knows about this issue, please let me know with the proper solution.
    Thanks for your immediate response!
    Regards,
    Lakshman

    CREATE OR REPLACE TRIGGER INPL.trigger_new
    AFTER INSERT OR UPDATE OR DELETE
    ON TABLE_NEW REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    action_flag VARCHAR2(1);
    new_image BLOB;
    BEGIN
    IF UPDATING
    THEN
    action_flag := 'U';
    ELSIF DELETING
    THEN
    action_flag := 'D';
    ELSIF INSERTING
    THEN
    action_flag := 'I';
    END IF;
    IF (:NEW.image = :OLD.image)
    THEN
    new_image := '';
    ELSE
    new_image := :NEW.image;
    END IF;
    INSERT INTO TABLE_AUD(action_flag, date_changed,nimage,oimage) values(new_image,:old.image);
    end;
    I am getting the error in line at If condition
    Error: PLS-00306: Wrong number or tpyes of arguments in call '='
    Please let me know if any one knows exact solution!
    Thanks in advance!
    Regards,
    Lakshman

  • Error in Creating Trigger

    Hi All,
    I have a problem in creating a trigger.
    I have two fields named last_updated_by, last_updated_date which
    r common to all the tables.
    If the user made any change to the exiting record, the values of
    the those two colums should get changed automatically with the
    username and sysdate.
    When I wrote a trigger its giving mutation error.
    Can I update these value by stored procedure via trigger?
    I heard its possible by DBMS_JOB package. Can anyone give idea?
    Thanks in Advance.
    Regards
    Gopinath Kona

    You should only get the mutating table probllem if you're doing
    SELCT or DML against the table the trigger's built on. Which
    suggests that you're approaching this the wrong way.
    Try CREATE TRIGGER blah blah
    FOR EACH ROW
    :new.last_updated_by := USER;
    :new.last_updated_date := SYSDATE;
    END;
    If that's what you are doing then the problem lies elsewhere.
    Rgds, APC

  • Error while create trigger on for nested table

    I want to insert a record into a nested table.For this, I created a view for the table, which includes the nested table.It told me ORA-25015 cannot perform DML on this nested table view column.So I created a trigger for the nested table.However, it told me that ORA-25010 Invalid nested table column name in nested table clause.I think my nested table is valid, i don't konw why did it appear this kind of problem?
    My table is
    CREATE TABLE ENT
    ID NUMBER(7) NOT NULL,
    CREATE_DATE VARCHAR2(11 BYTE),
    UPDATE_DATE VARCHAR2(11 BYTE),
    DEPTS VARRAY_DEPT_SEQ
    CREATE OR REPLACE
    TYPE DEPT AS OBJECT
    ID NUMBER(8),
    ANCHOR VARCHAR2(20),
    CREATE OR REPLACE
    TYPE " VARRAY_DEPT_SEQ" as varray(930) of DEPT
    CREATE OR REPLACE VIEW ENT_NESTED_VIEW
    (ID, CREATE_DATE, UPDATE_DATE, DEPTS)
    AS
    select e.ID,cast(multiset(select r.id,r.anchor from ent z, table(z.depts) r where z.ID=e.ID )as varray_dept_seq)
    FROM ENT e
    Then when I created trigger;
    CREATE OR REPLACE TRIGGER EMP.ENT_NESTED_TRI
    INSTEAD OF INSERT
    ON NESTED TABLE DEPTS OF EMP.ENT_NESTED_VIEW
    REFERENCING NEW AS New OLD AS Old PARENT AS Parent
    FOR EACH ROW
    BEGIN
    END ;
    I met the problem: ORA-25010 Invalid nested table column name in nested table clause
    Could you please tell me the reason
    Thank you!
    My insert SQL is:
    insert into table(select depts from ent_nested_view where id=1856) values(varray_dept_seq(dept(255687,'AF58743')))
    Message was edited by:
    user589751

    Hi,TongucY
    Compared with the "Referencing Clause with Nested Tables" part of this reference -
    http://psoug.org/reference/instead_of_trigger.html, I found the answer of this
    quesion. That is "CREATE OR REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of
    DEPT". It turns to be a varying array, not a nested table. It should be "CREATE OR
    REPLACE TYPE " VARRAY_DEPT_SEQ" as table of DEPT". That is OK. Thank you very
    much!
    While there is an another question, if I create a varying array like" CREATE OR
    REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of DEPT " and I want to insert
    a record into the varying array, which the record has been existed.The method that
    create a view and a trigger seems not to be effective.
    For instance,
    There is a record in the table
    ID:1020
    CREATE_DATE:2005-10-20
    UPDATE_DATE:2007-2-11
    DETPS: ((10225,AMY))
    I want to ask this record to be
    ID:1020
    CREATE_DATE:2005-10-20
    UPDATE_DATE:2007-2-11
    DETPS: ((10225,AMY),(10558,TOM))
    How should I do?
    Could you please help me?
    Best regards.
    Message was edited by:
    user589751

  • Bad bind variable error on creating trigger

    hi
    im trying to create a trigger on a table in Oracle and I keep gettin this error:
    PLS-00049: bad bind variable 'NEW.ID'
    TeamID is a primary Key, it creates the sequence fine, but i get the error on the create trigger,
    CREATE TABLE TBLTEAMS
    TEAMID NUMBER(5),
    NAME VARCHAR2(50 BYTE),
    MANAGER VARCHAR2(50 BYTE),
    COSTCENTRE NUMBER(9),
    PARENTTEAMID NUMBER(5)
    create sequence seq_Teamsautonumber;
    create trigger trg_Teamsautonumber
    before insert on tblteams
    for each row
    begin
    select seq_Teamsautonumber.nextval into :new.id from dual;
    end;
    any ideas?

    You have said
    :new.idthat means you are trying to load the sequence value into a column that doesn't exist in your table.
    you would need to use
    :new.teamidAssuming you are trying to auto-populate the TEAMID column on your table.

  • I create trigger but not display massage after insert in oracle 10g

    I create trigger but not display massage after insert in oracle 10g
    **CREATE OR REPLACE TRIGGER TableName**
    **AFTER INSERT OR DELETE OR UPDATE ON test**
    **BEGIN**
    **if inserting then**
    **dbms_output.put('Message');**
    **end if;**
    **END;**

    What user interface are you using?
    If the tool doesn't support the SQL*Plus syntax (set serveroutput on), it probably has an option somewhere to enable DBMS Output. Not even knowing what tool you're using, it's impossible for us to guess where that option might be configured.
    As others have suggested, using DBMS Output to test code is less than ideal because you're dependent on the application you're using to display it to you and not every application can or will do that. If you want to use DBMS_Output, you may need to switch to a different GUI (SQL Developer or SQL*Plus are both free utilities from Oracle). Otherwise, you'd probably be better off having the trigger do something that you can subsequently query (i.e. write a row to a log table).
    Justin

  • Create trigger not audited when run from sql developer Version 3.2.20.09

    Creating or editing a trigger is not being stored in the audit table when run from sql developer.
    Here is a sample script to show the issue:
    Grant Connect,create table,create trigger To testuser Identified By testuser;
    create table testuser.testtab(t1 number);
    Select Count(*) From Dba_Audit_Trail Where Owner='TESTUSER';
    CREATE OR REPLACE TRIGGER testuser.testtab_bi_trg BEFORE
      Insert
          ON testuser.testtab FOR EACH ROW
    begin
      null;
    end;
    Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';
    drop user testuser cascade;
    If I run the script from sql developer the CREATE TRIGGER statement does not get audited.
    If I run the script from sql plus or All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.
    If I edit the trigger from sql developer the CREATE TRIGGER statement does not get audited.
    If I edit the trigger from  All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.

    DoyleFreeman wrote:
    Not sure what you mean by "perform the audit".
    Have you tested my script? Does the "Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';" increment by 1 after each of the ddl statements or only after the Create table statement.
    Your question doesn't have ANYTHING to do with sql developer and should be posted in the Database General forum
    https://forums.oracle.com/community/developer/english/oracle_database/general_questions
    Yes - and it works just fine once you ENABLE AUDITING. Your scripIt  does NOT include the statements or code used to ENABLE auditing and, specifically, enable auditing for triggers.
    Auditing doesn't just 'happen'; you have to enable it and you have to specify any non-default auditing that you want to perform.
    Have you read any of the extensive documentation about auditing to learn how to use it?
    See the Database Security Guide
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm
    Also see 'Auditing Functions, Procedures, Packages, and Triggers
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm#BCGBEAGC
    And see the AUDIT statement in the SQL language doc for how to specify auditing of specific operations.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4007.htm
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    0
    audit create trigger by scott
    CREATE OR REPLACE TRIGGER emp_copy_bi_trg BEFORE
      Insert
          ON emp_copy FOR EACH ROW
    begin
      null;
    end;
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    1

  • Create Trigger (PK from Sequence) in SQL Developer 1.5.1

    Hi all
    I'm new to Oracle and am trying to create the equivalent of an autonumber field on a table using the Create Trigger (PK from Sequence) option (by right clicking on a table in SQL Developer).
    I've set up a sequence called REQUESTID and when using the above option it generates the following SQL:
    begin
    execute immediate 'create or replace trigger AutoNumber '||
         ' before insert on "REQUEST" '||
         ' for each row '||
         'begin '||
         ' if inserting then '||
         ' if :NEW."REQUESTID" is null then '||
         ' select REQUESTID.nextval into :NEW."REQUESTID" from dual; '||
         ' end if; '||
         ' end if; '||
         'end;';
         end;
    When I click Apply I get an ORA-00942 (table or view does not exist). Am I doing something daft here?

    Never mind - sorted it - I created the table under a different Schema to the System login being used in SQL Developer and so didn't have the permissions to create the trigger on the table.

  • Problem in after create  trigger

    hi all,
    i tried to track the creation of all objects in scott user. so from one dba user
    i wrote a After Create trigger for scott schema(schema level trigger) like this,
    create trigger create_log after create on scott.schema
    begin
    insert into create_log_t values(login_user,sysdate,dictionary_obj_type,dictionary_obj_name);
    end;
    trigger has been successfully created.After that i tried to create some objects in scott schema,but i could not. it gives me this error,
    SQL> create table dd(d number);
    create table dd(d number)
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00984: column not allowed here
    ORA-06512: at line 2
    can anyone help me to come out from this problem.
    thanks in advance!
    kathir

    What is LOGIN_USER? Did you mean USER?
    Cheers, APC

  • Multiple CREATE TRIGGER's in SQL file

    I have an SQL file which contains multiple CREATE TRIGGER statements. I can't run it as it stands in SQLPlus Worksheet because it doesn't recognise the
    end;
    as the end of the create trigger statement and fails on the next CREATE line.
    Is there a way I can get this file to process. I can run each statement individually, but there's a lot of them.
    Any thoughts much appreciated.
    Thanks in advance.

    Just for clarity within your file, you may want to do the following
    Create or Replace Trigger TG_One
      before insert on mytab_two
      for each row
    declare
      adt_exists           EXCEPTION;
    begin
    end TG_One ;
    Create or Replace Trigger TG_Two
      before insert on mytab_three
      for each row
    declare
      adt_exists           EXCEPTION;
    begin
    end TG_Two ;

  • How to create trigger through Java programm?

    I write a Java programm to create a trigger(through JDBC connection). After I run the programm, a trigger was created in Oracle 10g.But the trigger is invalid. After Compiling the trigger , a error "PLS-00103 " occured .But if I excute the SQL in SQL developer,the trigger was created successfully.
    If there is some special considerations should be taken when using programm to create trigger?
    My Java programm fragment as follows:
         public void createTrigger() throws SQLException{
              Statement stmt = conn.createStatement();
              stmt.executeUpdate(getCreateTriggerSql());
    Edited by: jerry on 2010-6-29 下午6:42

    Yes the special consideration is you shouldn't perform DDL on the fly, as it has all kinds of unwanted side effects like implicit commits.
    If I would start a company, and I discover one of my developers is writing this kind of program, I would fire him, on the spot.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • HELP!: MacBook Pro Keyboard and Trackpad freeze...

    Good Afternoon, Yesterday afternoon, I turned on my MacBook Pro and a few seconds after bootup the trackpad became unresponsive, I then tried to perform a restart with the aid of the keyboard however, I then, noticed that my MBP keyboard also became

  • CAN'T SEND MAIL WITH OS X MAVERICKS 10.9.4

    Hi everyone. I have an issue and need help. Since this afternoon, I am not able to send my email from my iCloud account in OS X 10.9.4. I have purchased a new machine and was loading up my account settings. It was going OK, but then this issue. Now i

  • [SOLVED]Can't open shared files in Thunar

    While waiting for Gnome 3 I decided to give Openbox a spin in a separate Arch install, using Thunar as the filemanager. Everyting is working fine except opening files from samba shares. My permissions are fine, because I can delete and write files an

  • Cumulative Balances in PCA Balance Sheet cube are not correct.

    Hi Could you please help me in sorting out this Issue. Cumulative Balances in PCA Balance Sheet cube are not correct. After doing a reconciliation my conclusions are: Opening balance for 2005 (fiscal period 009.2005) is not in BW Opening balance for

  • Rollup process is getting failed in PC

    Hi, The Rollup job gets failed daily in PC with following error message " Error when structuring the index of aggregate 100929 for InfoCube /BIC/FICPROB "and once i repeat the job it will get success. I need to know the reason why it get fail, if any