Database triggers

Is there any way to find the name of the table from withing the trigger code?
Thanks

I guess you mean this.
ALL_TRIGGERS
ALL_TRIGGERS describes owned by the current user and triggers on tables owned by the current user. If the user has the CREATE ANY TRIGGER privilege, then this view describes all triggers in the database.
Related Views
DBA_TRIGGERS describes all triggers in the database.
USER_TRIGGERS describes all triggers owned by the current user. This view does not display the OWNER column.
Column Datatype NULL Description
OWNER
VARCHAR2(30)
NOT NULL
Owner of the trigger
TRIGGER_NAME
VARCHAR2(30)
NOT NULL
Name of the trigger
TRIGGER_TYPE
VARCHAR2(16)
When the trigger fires: BEFORE STATEMENT, BEFORE EACH ROW, BEFORE EVENT, AFTER STATEMENT, AFTER EACH ROW, and AFTER EVENT
TRIGGERING_EVENT
VARCHAR2(216)
The DML, DDL, or database event that fires the trigger. For a listing of triggering events, see the CREATE TRIGGER statement in Oracle9i SQL Reference.
TABLE_OWNER
VARCHAR2(30)
NOT NULL
Owner of the table on which the trigger is defined
BASE_OBJECT_TYPE
VARCHAR2(16)
The base object on which the trigger is defined: TABLE, VIEW, SCHEMA, or DATABASE
TABLE_NAME
VARCHAR2(30)
If the base object type of the trigger is SCHEMA or DATABASE, then this column is NULL; if the base object type of the trigger is TABLE or VIEW, this columns indicates the table/view name on which the trigger is defined
COLUMN_NAME
VARCHAR2(30)
Name of the nested table column (if nested table trigger), else null
REFERENCING_NAMES
VARCHAR2(87)
Names used for referencing OLD and NEW column values from within the trigger
WHEN_CLAUSE
VARCHAR2(4000)
Must evaluate to TRUE for TRIGGER_BODY to execute
STATUS
VARCHAR2(8)
Whether the trigger is enabled (ENABLED|DISABLED)
DESCRIPTION
VARCHAR2(4000)
Trigger description; useful for re-creating a trigger creation statement
ACTION_TYPE
VARCHAR2(11)
The action type of the trigger body (CALL or PL/SQL)
TRIGGER_BODY
LONG
Statement(s) executed by the trigger when it fires
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch2154.htm#1304423
Joel P�rez

Similar Messages

  • Can we use TCL commands in database triggers?

    Hi,
    GoodDay, This is Ramesh. Please let me know that, can we use TCL (Commit, Rollback & Savepoint) commands in our[b] DATABASE triggers? If so how..?
    Regards,
    Ramesh.

    Hi Ramesh, you're in the wrong forum; SQL Developer is a tool. Try SQL And PL/SQL...
    Regards,
    K.

  • How to create database triggers in ABAP Dictionary

    Hi,
    How can i create database triggers on tables, like the update, delete and insert triggers which we used to create in SQL sever and other databases, is there any transaction for doing the same from ABAP dictionary. or should it be done at the raw database level.
    Thanks
    Akila.R

    Hi,
    please check out the following link it might help you
    http://help.sap.com/saphelp_nw2004s/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm
    *************please reward points if the information is helpful to you******************

  • Database triggers VS Front end triggers

    Hi All,
    We have online ticket reservation application developed using oracle forms 6i and Oracle 8i database in Client server multiuser environment.
    for example we have scenario like this.. AFTER INSERTING into TABLE A,
    we need to UPDATE status column in TABLE B, for achieve this which is better option
    To write database trigger on A,
    or To write a POST INSERT trigger in the form designed uisng TABLE A.
    basically the the dataentry is done through Front end only.
    we are going to have upto 20 triggers of this scenario in the entire database on diffrent tables.
    which is best practice? in terms of performance.
    And we want to have DAY END, DAY CLOSE system, so that once we close DAY, no one allowed to insert data into few tables, for this can we use database triggers or front end check.
    Thanks in advance

    There isn't a confusion here between "application" meaning front-end tool, and "application" meaning "whatever layer contains your business logic" is there? I didn't mean to suggest that i thought it a good idea that business logic be implemented outside of the database, just that it ought to all be in one layer -- my own choice would be db packages, but if someone were commited to putting business logic outside of the db, then that would be the place for all the code.

  • Error running utility "Maintain database triggers to circumvent mut tab"

    Hi,
    I succesfully runned the utility to create the table package, but when running the database triggers utility I receive:
    Message
    Activity aborted with ORACLE internal errors.
    -6502 ORA-06502: PL/SQL: numeric or value error: number precision too large
    I tried on a smaller table and that one is running ok. Is there a maximum on e.g. columns to have the utility work proper?
    Or is there perhaps the column_name what can be the problem?
    Regards
    Jessica
    null

    Jessica,
    It sounds like bug 897808 (HSDUTL). It should be fixed in Headstart 2.1.2 patch 11. Are you sure you installed this? Note that installing patch 12 doesn't install patch 11.
    If this is indeed the problem you are running into, the offending statement is located in the package HSU_CCMR (revision 2.1.0.2). Within the procedure add_block the variable l_number_of_lines is declared as a number(2), this should be changed to a number(3).
    Kind Regards,
    Peter

  • Database Triggers in "Offline Database Sources" - where are they?

    Hello,
    Can I import database triggers into Offline Database Sources in JDev 10.1.3.3 ? If so, how? If not, why not?
    Thanks in advance,
    Chris

    Chris,
    "Can I import database triggers into Offline Database Sources in JDev 10.1.3.3 ?" No
    "If not, why not?" Because there is no support in JDev for doing so ;)
    JDeveloper 11g does have support for this. What I do in 10g is to create a SQL file and store my trigger code in there.
    Best,
    John

  • Replacing / Compiling Database Triggers in a HA/High Load system

    Hi there,
    My collegue has just asked me if downtime needs to be scheduled to replace an After IUD Database trigger where I've made a minor change.
    If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.
    What about when working with database triggers?
    If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?
    Notes:
    Oracle 10g R2 db.
    High DML rates on the table that the After IUD Trigger is 'attached' to.
    It's a near certainty that when the Create or Replace Trigger DDL runs, the trigger will be active at the time.
    The Trigger is 'simple' in that it's use: is to call a DB package with some of the :new values as params.
    +(I'm happy to rtfm - if someone can tell me where!!)+
    Cheers -
    Ron Marks

    If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.Not true. This exception is thrown only if sessions have some state represented in package variables. If there is no associated session state, then no exception would be thrown after recompile.
    If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?You'll wait - to lock an object in library cache which represents your trigger. Not sure if this would require a library cache lock on underlying table, but I would guess that it is required. BTW, locking a table would make no any sense: CREATE TRIGGER is a DDL, which means before it began it issues a COMMIT => all locks are released, and it is quite possible that a TM lock for CREATE TRIGGER won't be acquired since resource would be busy.
    Oracle 11gR2 claims to address problems of application upgrades on a high-load environments with a feature called "Editions" (not a good name - try to find something about it via Google...)

  • Server / Database triggers

    Here is my development teams, there are some naughty developer doing something bad things by themselves like create db, create jobs....etc~ some even know the sa password
    apart from blocking/disable sa, change sa password, am I able to create DDL trigger on SERVER, which this trigger can only modify/delete by the creater , not SA

    There is nothing to stop sa from doing anything.
    While DDL triggers can be good to audit what is going on at the server and in the databases, they are not good for preventing actions. Particularly, one must understand that they fire after the action. A DDL trigger to prevent indexes being created during
    office hours is entirely contraproductive.
    From what you describe, you need to tighten security. Rename sa, change the password, write it down and lock it into a safe.
    And for the rest, be considerate with the permissions you hand out. Although, there is always the problem that too much security goes in the way, and this is why auditing is a good way. But for auditing to work, you need to get sa and all other anonymous
    accounts out of the way, so that everyone can he held accountable for their actions.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to run Unix Host commands from Database Triggers?

    Hi
    I need to create few directories in the Unix O/s under a specific directory (From a Database Trigger). And the directory names will be determined in the DB Trigger based on the data.
    I hope someone would have come across a requirement like this and will be able to help me out.
    Thanks.
    Mohan

    Hi Christopher
    How is it possible to use System calls from Triggers. Is it possible to use Runtime Libraries in DB Triggers.
    Thanks
    Mohan
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Christopher Racicot ([email protected]):
    Try using the system calls available in
    the C runtime library by calling an external
    C procedure from the trigger. We will be
    enhancing the support in UTL_FILE to address
    issues like this in an upcoming release,
    but for now an external procedure should
    do the trick.<HR></BLOCKQUOTE>
    null

  • Interesting issue with Logical Standby and database triggers

    We have a Logical Standby that each month we export (expdp) a schema (CSPAN) that is being maintained by SQL Apply and import (impdp)it to a 'frozen copy' (eg CSPAN201104) using REMAP_SCHEMA.
    This works fine although we've noticed that because triggers on the original schema being exported have the original schema (CSPAN) hard-referenced in the definition are imported into and owned by the new 'frozen' schema but are still 'attached' to the original schema's tables.
    This is currently causing the issue where the frozen schema trigger is INVALID and causing the SQL Apply to fail. This is the error:
    'CSPAN201104.AUD_R_TRG_PEOPLE' is
    invalid and failed re-validation
    Failed SQL update "CSPAN"."PEOPLE" set "ORG_ID" = 2, "ACTIVE_IND" = 'Y', "CREATE_DT" = TO_DATE('22-JUL-08','DD-MON-RR'),"CREATOR_NM" = 'LC', "FIRST_NM" = 'Test', "LAST_PERSON" ='log'...
    Note: this trigger references the CSPAN schema (...AFTER INSERT ON CSPAN.PEOPLE...)
    I suspect that triggers on a SQL Apply Maintained schema in a Logical Standby do not need to be valid (since they do not fire) but what if they reference a SQL Apply schema but are 'owned' by a non-SQL Apply schema? This trigger references a SQL Apply table so it should not fire
    This is 10gR2 (10.2.0.4) on 64 bit Windows.
    Regards
    Graeme King

    OK, I've finally got around to actually test this and it looks like you are not quite correct Larry in this statement...
    'Since this trigger belongs to a new schema that is not controlled by SQL Apply (CSPAN201105) it will fire. But the trigger references a schema that is controlled by SQL Apply (CSPAN) so it will fail because it has to be validated.'
    My testing concludes that even though the trigger belongs to a schema CSPAN201105 (not controlled by SQL Apply) and references a schema controlled by SQL Apply - it does not fire. However it DOES need to be valid or it breaks SQL Apply.
    My testing was as follows:
    Primary DB
    Create new EMP table in CSPAN schema on Primary
    Create new table TRIGGER_LOG in CSPAN schema on Primary
    Create AFTER INSERT/UPDATE trigger on CSPAN.EMP table (that inserts into TRIGGER_LOG table)
    **All of the above replicates to Standby**
    Standby DB
    Create new table TRIGGER_LOG_STNDBY in CSPAN201105 schema on Primary
    Create new trigger in CSPAN201105 schema that fires on INSERT/UPDATE on CSPAN.EMP but that inserts into CSPAN201105.TRIGGER_LOG_STNDBY table)
    Primary DB
    Insert 4 rows into CSPAN.EMP
    Update 2 rows in CSPAN.EMP
    TRIGGER_LOG table has 6 rows as expected
    Standby DB
    TRIGGER_LOG table has 6 rows as expected
    TRIGGER_LOG_STNDBY table has **0 rows**
    Re-create trigger in CSPAN201105 schema that fires on INSERT/UPDATE on CSPAN.EMP but that inserts into CSPAN201105.TRIGGER_LOG_STNDBY table) **but with syntax error**
    Primary DB
    Update 1 row in CSPAN.EMP
    TRIGGER_LOG table has 7 rows as expected
    Standby DB
    SQL Apply is broken - ORA-04098: trigger 'CSPAN201105.TEST_TRIGGER_TRG' is invalid and failed re-validation

  • Creating database triggers  from forms

    what we can create a data base trigger from from .if yes plzzz tell me its procedure.

    Yes, and have a look here, It show how is possible
    [url http://www.oracle.com/webapps/online-help/forms/10g/state/content/navId.3/navSetId._/vtTopicFile.designing_forms%7Cstoredpr%7Cf50crdbtr%7Ehtml/]Creating a Database Trigger

  • How to create Database Triggers

    Hi Experts,
    We have this following requirement.
    Some external program is going to update a custom table. Whenever these updates will occur we need to maintain changes in another database table. How can we achieve this requirement?
    Thanks in advance.
    Regards,
    Sayan

    Hi,
    Some external program is going to update a custom table. Whenever these updates will occur we need to maintain changes in another database table. How can we achieve this requirement?
    You can take help of SAP ABAP code with remote database connection parameters. Use some native sql to fetch and update data.
    Regards,
    Deepak Kori

  • Database Triggers - Autonomous Transaction Issue

    Hi ,
    I have a EMP table.
    I wrote a AFTER ROWLEVEL Database Trigger for EMP table.
    While Updating value in EMP table , my trigger is firing.
    Issue:
    My requirement is , I want to find the Count(1) in EMP table for the updated record.It is not including the updated record in my count.
    If i execute the count(1) , outside the session , it is giving the correct value.But inside trigger i am not getting the exact count.
    Can u pls help me.
    Sample Coding:
    While updating DEPT_CODE , the following trigger is firing.
    CREATE OR REPLACE TRIGGER testing
    AFTER UPDATE OF DEPT_CODE
    ON EMP
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    t_count number;
    cursor c_emp
    is
    select count(1)
    from emp
    where dept_code = :NEW.DEPT_CODE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    open c_emp;
    fetch c_emp into t_count;
    close c_emp;
    dbms_output.put_line('t_count '||t_count);
    END;
    I got count as 5.
    But if i execute the count in SQL , it is giving count as 4.
    In the database trigger , it is not taking the record which was updated .

    why a trigger (... not even going to ask why an autonomous trigger... )
    SQL> drop table t
      2  /
    Table dropped.
    SQL>
    SQL> create table t
      2  as
      3  select rownum id
      4    from all_objects
      5   where rownum <= 10
      6  /
    Table created.
    SQL>
    SQL>
    SQL> var cnt_upd number
    SQL>
    SQL> update t
      2     set id = id + 1
      3   where id > 5  
      4    returning count(id) into :cnt_upd
      5  /
    5 rows updated.
    SQL>
    SQL> print
       CNT_UPD
             5
    SQL>

  • How to use dll commands using or in database triggers...

    I want to use a dll command such as drop table table_name in the database trigger, is it possible ???
    If yes then please write me the codings, Thanks.....

    > I want to use a dll command such as drop table table_name in the database trigger, is
    it possible ???
    The question is not whether it is possible - and if you are indeed an OCP as you seem to claim with you handle, you should know the answer to this.
    The question is whether it is at all sensible from a functional perspective and a transaction processing perspective, to do this. And again, the answer to this should be quite clear as a DDL cannot be part of that trigger's transaction. Which means when that transaction is rolled back, the damage has been done - as the DDL executed by the trigger cannot be rolled back.
    > If yes then please write me the codings,
    So you are saying that you are incapable of writing any code? Then what on earth are you doing in a programmer's forum? Ask your supervisor/boss to give the problem to a real programmer to solve.

  • Capturing Custom Error Messages from Database Triggers

    Hi Everybody
    When i fired a trigger it should show only the custom message from RAISE_APPLICATION_ERROR
    instead of showing all the message....
    ORA-20103: We Cannot Delete the emp_id 5610
    ORA-06512: at "emp_id", line 89
    ORA-04088: error during execution of trigger 'delete_emp_id.trg'I want to show only the custom message
    We Cannot Delete the emp_id 5610Thanks in Advance

    Not possible AFAIK.
    Instead of RAISE_APPLICATION_ERROR, define a custom exception, call it and just print it onto the console (using dbms_output). You can't pop it out though.

Maybe you are looking for