Finding table name on which a trigger fired.

I need my trigger to report the name of the table and the DML event that caused the "for each row" trigger to fire.
How do I have the trigger identify this information without hardcoding the table name and event into the trigger ?

Actually, I blieve that you can find the name of the trigger by looking in the call stack trace. I think I have seen code for this posted at asktom (asktom.oracle.com).
To find the triggering statement you can do the following providing you have version 9+:
set echo on
create table t ( x int );
create or replace trigger t_trigger
before insert on t
declare
l_text ora_name_list_t;
begin
dbms_output.put_line( 'The statement that caused me to fire is:' );
for i in 1 .. ora_sql_txt( l_text )
loop
dbms_output.put_line( l_text(i) );
end loop;
end;
set serveroutput on
variable n number
insert /* check this out */ into t values ( :n );
drop table t
I forgot where I stole this code from but it was probably posted on comp.databases.oracle.server or asktom.
HTH -- Mark D Powell --

Similar Messages

  • How To Find Out Table Name At Database Level Trigger

    Table Name
    How do I will come to know the name of table on which currently DML statement is fired ?
    e. g. My current user is SCOTT. So Scott should realize the event of DML Statement fired. Hence my question is how the trigger on User Level is to be written & how to catch the event & table name on which the statement is being executed.
    Suppose my table is as follows
    Table Name : EMP
    EMPNO number
    ENAME varchar2(10)
    JOB varchar2(9)
    MGR number
    HIREDATE date
    SAL number
    COMM number
    DEPTNO number
    Bcd number
    Brcd number
    Rec_id number
    Scn_no number
    Sequences for above table
    1. EMP_REC_ID - minimum value is 1 increment by 1 & max value is unlimited
    2. EMP_SCN_NO - minimum value is 1 increment by 1 & max value is unlimited
    I have written a trigger as follows :
    CREATE OR REPLACE TRIGGER UPD_EMP_REC_SCN BEFORE INSERT OR UPDATE OR DELETE ON EMP REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
    DECLARE
    BEGIN
    IF (INSERTING) THEN
    SELECT EMP_REC_ID.NEXTVAL INTO :NEW.REC_ID FROM DUAL;
    ELSIF (UPDATING) THEN
    SELECT EMP_SCN_NO.NEXTVAL INTO :NEW.SCN_NO FROM DUAL;
    ELSIF (DELETING) THEN
    INSERT INTO DELETED_ROWS (TAB_NAME, BCD, BRCD, REC_ID)
    VALUES (‘EMP’, :OLD.BCD, :OLD.BRCD, :OLD.REC_ID);
    END IF;
    END;
    Hence My problem is
    If my database user contains 800 tables then I have to write down 800 triggers (i.e. for each table).
    I want to write only one trigger at database level so that I can dynamically take actions, for this I need table name and the event on which the dml event has taken place.
    Any help in this matter will be greatly appreceiated.
    Regards
    Vikrant

    You cannot write a single trigger that applies to multiple tables. If you need a trigger for every table, you will need to generate 800 triggers.
    Rather than manually generating 800 triggers, you might write a code generator that generates triggers for each of the tables by querying the data dictionary (i.e. DBA_TABLES, DBA_TAB_COLS, etc).
    Justin

  • Find out user exits which should trigger while saving billing doc.(VA01)

    Hi All,
    please can u help me to find out user exits which should trigger while saving billing documents for VA01 transaction...I have already z report to find the user-exit for any transaction.I have tried in that also.
    Reply
    Ulhas

    Hi
    Try these
    USEREXIT_NUMBER_RANGE (Module pool SAPLV60A, program RV60AFZZ)                    
    The internal number range used in the standard system is specified                
    in the billing type table and can be changed in this user exit. This              
    user exit is only called when the billing documents is created.                                                                               
    USEREXIT_ACCOUNT_PREP_KOMKCV (Module pool SAPLV60A, program                       
    RV60AFZZ)                                                                         
    In this user exit additional fields for account determination that                
    are not provided in the standard system are copied into                           
    communication structure KOMKCV (header fields).                                                                               
    USEREXIT_ACCOUNT_PREP_KOMPCV (Module pool SAPLV60A)                               
    In this user exit additional fields for account determination that                
    are not provided in the standard system are copied into                           
    communication structure KOMPCV (item fields).                                                                               
    USEREXIT_NUMBER_RANGE_INV_DATE (Module pool SAPLV60A, program                     
    RV60AFZC)                                                                         
    Depending on the number range, table TVFKD is used to set the                     
    billing date (country-specific requirments in Italy).                             
    USEREXIT_NUMBER_RANGE is automatically deactivated when this user                 
    exit is being applied.                                                                               
    USEREXIT_FILL_VBRK_VBRP (Module pool SAPLV60A, program RV60AFZC)                  
    This user exit is only called when the billing document is created.               
    It is used to provide the header and the item of the new billing                  
    document with deviating or additional data.                                       
      USEREXIT_PRINT_ITEM (Module pool SAPLV61A, program RV61AFZB)                    
      Printing the item line of a billing document can be supplemented or             
      changed.                                                                               
    USEREXIT_PRINT_HEAD (Modulpool SAPLV61A, Programm RV61AFZB)                     
      Printing the header line of a billing document can be supplemented              
      or changed.                                                                               
    User exits in program RV60AFZD                                                  
      Short descriptions of the user exits are contained in the program:                                                                               
    -   USEREXIT_RELI_XVBPAK_AVBPAK                                                                               
    -   USEREXIT_NEWROLE_XVBPAK_AVBPAK                                                                               
    -   USEREXIT_NEWROLE_XVBPAP_AVBPAK                                                                               
    e following user exits are available in report SAPLV60B for transfer              
    accounting (function group V60B):                                                                               
    EXIT_SAPLV60B_001: Change the header data in the structure acchd                
      You can use this exit to influence the header information of the                
      accounting document. For example, you can change the business                   
      transaction, "created on" date and time, the name of the person who             
      created it or the transaction with which the document was created.                                                                               
    EXIT_SAPLV60B_002: Change the customer line ACCIT                               
      You can use this exit to change the customer line in the accounting             
      document. This exit is processed once the ACCIT structure is filled             
      in with data from document header VBRK.                                                                               
    EXIT_SAPLV60B_003: Change the customer line in costing                          
      The customer line is filled in differently for costing. You can use             
      exit 003 to influence the ACCIT structure.                                                                               
    EXIT_SAPLV60B_004: Change a GL account item ACCIT You can add          
    information to a GL account item (such as quantity specifications)     
    with this exit.                                                                               
    EXIT_SAPLV60B_005: User exit for accruals                              
    Once all relevant data for accruals was entered in the GL account      
    item, you can add to this data with this exit.                                                                               
    EXIT_SAPLV60B_006: Change the control line ACCIT                       
    You can use exit 006 to add information to the control line.                                                                               
    EXIT_SAPLV60B_007: Change the installment plan                         
    You can use exit 007 to add information to the installment plan        
    parameters in the GL account item.                                                                               
    EXIT_SAPLV60B_008: Change the transfer structure ACCCR, ACCIT and      
    ACCHD                                                                  
    After the accounting document is filled in with data, you can use      
    exit 008 to change the document once again.                                                                               
    EXIT_SAPLV60B_010: Item table for customer lines                       
    You can use exit 10 to influence the contents of customer lines        
    before they are created.                                                                               
    EXIT_SAPLV60B_0011: Change the parameter for cash account              
    determination or reconciliation account determination                  
    You can use this exit to change inbound parameters in order to         
    influence account determination.                                       
    >                                                                      
    Thanks
    Shiva

  • Find table name and constraint type based on field name

    I have a field or column name with me...I want to find the table name for which it is a primary key...Any query to do this job so that the execution costs are low...
    Currently i have to mix dba_constraints and ALL_TAB_COLUMNS to get this...any way to fetch the data from a single table/anyother cost effective process is appreciated

    Why are you using dynamic SQL? Just place it as static SQL in your PL/SQL code. Simply like this
    select table_name
       into ..
      from (
              select cc.column_name
                   , cc.table_name
                   , count(cc.column_name) over(partition by c.constraint_name) column_count
                from user_constraints c
                join user_cons_columns cc
                  on c.constraint_name = cc.constraint_name
               where constraint_type = 'P'
    where column_count = 1
       and column_name  = p_name;
    And in some case (Not this one) if you have to use dynamic SQL you need to pass your variables are bind variables to your SQL. You should not be appending it in the string. That's a very bad thing to do. Your code will be going for hard parse, your code will be exposed to SQL Injection. With your SQL this is how you use bind variable.
    execute immediate
    q'[
        select table_name 
          from (
                  select cc.column_name
                       , cc.table_name
                       , count(cc.column_name) over(partition by c.constraint_name) column_count
                    from user_constraints c
                    join user_cons_columns cc
                      on c.constraint_name = cc.constraint_name 
                   where constraint_type = 'P'
         where column_count = 1
           and column_name  = :1
    using p_name
    into <your_variable>;
    And finally to exactly tell why your code is failing, You have not use sing quotes to enclose your p_name that you are appending to your code. Following would fix the error.
    DO NOT USE IT IN ANY CASE. ITS WRONG ALWAYS!!
    'select table_name  from '||' (
              select  cc.column_name,cc.table_name, count(cc.column_name) over(partition by c.constraint_name) column_count
                from user_constraints c join user_cons_columns cc
                  on c.constraint_name = cc.constraint_name  where constraint_type = ''P'') '||
    ' where column_count = 1 and column_name = '''|| p_name || '''';
    AGAIN NEVER WRITE A CODE AS SHOWN ABOVE.

  • How to find table name for the fields from Standard Extractor in CRM system

    How to find table name of fields from the standard extractor in CRM system ?
    e.g. We use LBWE TCode in R/3 system to find table name for the field from Extractor VCSCL(e.g.).
    Likewise is there any way to find table name for the fields from Standard extractor like 0CRM_LEAD_I.

    Hi ,
    Please find the link below for understanding BW CRM analysis.
    http://help.sap.com/bp_biv135/html/bw.htm
    activate the CRM DSs by scenario:
    1) Activate the application component hierarchy (tcode RSA9). Changes made to the application component hierarchy in the CRM system can be transferred to the BW using the "Edit Application Component Hierarchy" (SBIW - Postprocessing of DataSources).
    SAP Note 434886 must be implemented in CRM 3.0 before the application component hierarchy is activated.
    2) Activate the Business Content DataSources (tcode RSA5).
    Select/enter the application component and choose Execute (F8).
    To compare the shipped and active versions, choose the 'Select Delta' pushbutton. If there is no active version of the DataSource, it is selected automatically.
    To activate the shipped version, choose the 'Transfer DataSources' pushbutton.
    3) Management of the versions of the BW-Adapter metadata (tcode BWA5). All DataSources are displayed that are managed by the BW Adapter.
    As in transaction RSA5 (Service API Metadata Activation), the 'Select Delta' function can be used to select the inactive DataSources or compare shipped and active versions.
    You can also go directly to the screen for maintaining DataSources that are managed by the BW Adapter.
    The 'Compare Version' function makes a detailed comparison of the shipped and active versions.
    All BW-Adapter metadata is considered when versions are compared:
    Header information (Table SMOXHEAD)
    Mapping information (Table SMOXRELP)
    Global selection conditions (Table SMOXGSEL)
    Attribute key fields (Table SMOXAFLD)
    Hope this helps.
    Regards,
    csm reddy

  • Table name in which return item data is stored of a PO

    Can some please specify the table name in which return item data is stored of a PO?
    Thanks in advance;

    Hi,
    Let me explain what exactly I need. In a PO there is a checkbox "Retun Item". If we check that checkbox for an item that item becomes a retun item.
    I need to fetch all the data of this return Item. The commitment data goes to table COOI but this return item records doesn't get stored in COOI table. I need all the data of this entry including the Network Activity, Project, WBS element etc.
    Please let me know if you could help me.
    Thanks.

  • Table name from which to extract bank name and swift code by key field as vendor code

    Please help with the table name from which we can extract the bank name and swift code of vendors with the key input as vendor numbers

    Hello Subhadra, I'm sorry, I should've said join of LFBK and BNKA. The fields for the join will be the bank country(BANKS) and bank key (BANKL).
    If you have not found a docu on SQVI already, you can refer to this:
    How to create Report by using SQVI
    This is how your join should look in BASIS mode, your selection parameter should be vendor code LIFNR; output fields with be bank name BANKA and swift code SWIFT.

  • How to find Table names for PO & Invoices in SRM Standalnoe system SRM 7.0?

    Hi,
    How to find Table names for PO & Invoices in SRM Standalnoe system SRM 7.0? Please let me know.
    Thanks,
    Monica

    Hi,
    In SRM for all objects like SC ( BUS21210),BID,PO(BUS22010),Confirmation (BUS2203),invoice etc all the data stored
    in BBP_PDHGP and BBP_PDBEI  tables only, These is no separate tables..
    for your reference below are the few SRM tables
    BBP_PDACC  Account Assignment 
    BBP_PDATT  Document Attachment 
    BBP_PDBEH  Backend Specific Header Data 
    BBP_PDBEI  Backend Specific Item Data 
    BBP_PDBGP  Partner Extension Gen. Purchasing Data 
    BBP_PDBINREL  Transaction Object Linkage (EBP) 
    BBP_PDHCF  Set for Tabular Customer and Solution Fields on Hdr 
    BBP_PDHGP  Business Transaction Purchasing Information 
    BBP_PDHSB  Bid Invitation 
    BBP_PDHSC  Header Extension for Customer Fields 
    BBP_PDHSS  Hdr Extension for SAP Internal Enhancements (IBUs and so on)
    BBP_PDICF  Set for Tabluar Customer and Solution Fields on Itm 
    BBP_PDIGP  Business Transaction Item-Purchasing Information 
    BBP_PDISB  Bid Invitation/Bid-Specific Item Data 
    BBP_PDISC  Item Extension for Customer Fields 
    BBP_PDISS  Item Ext. for SAP Internal Enhancements (IBUs and so on) 
    BBP_PDLIM  Value Limit 
    BBP_PDORG  Purchasing Organizational Unit 
    BBP_PDPSET  Further Procurement Information 
    BBP_PDTAX  Tax 
    CDCLS  Cluster structure for change documents 
    CDHDR  Change document header 
    CDPOS_STR  Additional Change Document - Table for STRINGs 
    CDPOS_UID  Additional Table for Inclusion of TABKEY>70 Characters 
    CRM_JCDO  Change Documents for Status Object (Table JSTO) 
    CRM_JCDS  Change Documents for System/User Statuses (Table JEST) 
    CRM_JEST  Individual Object Status 
    CRM_JSTO  Status Object Information 
    CRMD_LINK  Transaction - Set - Link 
    CRMD_ORDERADM_H Business Transaction 
    CRMD_ORDERADM_I Business Transaction Item 
    CRMD_PARTNER  Partners 
    SROBLROLB  Persistent Roles of BOR Objects 
    SROBLROLC  Persistent Roles of Business Classes 
    SRRELROLES  Object Relationship Service: Roles 
    Thanks & Regards,
    Prasad S

  • How to find table name which provide data for the DataSource

    Hi friends,
    How to find the Table name which providing data for the Business content DataSources (Master Data). Is there any table or Transation which give datasource and Table name at once.
    Thanks&Regards
    Revathi

    Hi Revathi...........
    1)If the datasource is extracting data from any table.................open the datasource using RSO2..........there u will get the table name......
    2) If the datasource is extracting data from any view.............go to RSA2..........copy the view name..........go to SE11 >> give the view name >> and check..........
    3) If Datasource is Function module based............then u hav to check in RSA2 >> give the datasource name >> execute >> there u will find the Extract structure name......Copy the Extract Structure name >> Go to SE11 >> in the Data Element field give the Extract structure name >> Display >> From the Entry Help/Check tab u can get the Table name............
    If u double click on the Extractor..............u will get the Function Module..............from there also u can check that the FM extracting data from which tables............
    For Other datasources also...........u can get the structure name from here........
    4) If the Datasources r LO datasources............then u can get the table name in LBWE.............LO extractor - goto transaction LBWE.................... Select the maintenance link for your datasource............
    here in the right hand pane.........in the drop down box, you can see the structures associated with this extractor ........ just remove the MC for the structure names to get the base table names. e.g. EKKO for MCEKKO.
    5) There is a pattern for the Extract structure name for LO datasources.............for an example..........
    DataSource 2LIS_11_VAITM ......Extract structure name is  MC11VA0ITM
    2LIS_11_VAHDR  >> MC11VA0HDR
    Hope this helps.........
    Regards,
    Debjani.......

  • How to find Tables names which are updated or inserted data

    Hi,
    I need some help to know.
    I am submitting a form in Oracle OWS (Oracle Workforce Scheduling), but don’t know where exactly data is going in the tables or how many tables are going to updated.
    I want to know the table names which are update after the submitting the form.
    Thanks in advance....
    Regards,
    Saket

    I don't think so. Never heard of Oracle Workforce Scheduling. Is there a forum for that?
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    https://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Table name in which the trip history is stored.

    Hi All,
    I was trying to find out the table in which the trip history is stored but in vain could not. Can any one let me know the table name plz.
    Your help is very much appreciated.
    Thanks and Regards
    Sri

    FITV_REJECT                    Rejected Trips                            
    FTPT_IMR_SURFACE               IMR - Other Segments of Trip as Flights   
    FTPT_QT_ALTERN                 Quicktrip Trip Alternative                
    FTPT_QT_QTRIP                  Quicktrip Trip                            
    PTRV_ARCHIVE                   Administrative Table for Archived Trip Dat
    PTRV_BEIH_BEL                  Assignment of Receipts to a Subsidy for Tr
    PTRV_BEIH_TAG                  Assignment of Days to a Subsidy for Trips 
    PTRV_BEIH_WEG                  Assignment of Trip Segments to a Subsidy f
    PTRV_BEIHILFE                  Subsidies for Trips Home for Entire Separa
    PTRV_COMM_AMT                  Detail Data: Transfer to FM When Trip Save
    PTRV_COMM_ITM                  Header Data: Transfer to FM When Trip Save
    PTRV_F_FBLK                    Form Blocks of the Trip Costs Form        
    PTRV_F_FBLK_TXT                Form Blocks of the Trip Costs Form        
    PTRV_HEAD                      General Trip Data                         
    PTRV_PERIO                     Period Data of a Trip                     
    PTRV_REDUCTION                 Decision Fields: Change of Statutory Trip 
    PTRV_ROT_AWKEY                 Assignment of Trip Results to Posting Doc.
    PTRV_SADD                      Trip Statistics - Add. Receipt Data       
    PTRV_SBACKLOG                  Trip Statistics - Batch/Backlog Processing
    PTRV_SCOS                      Trip Statistics - Cost Assignment         
    PTRV_SHDR                      Trip Statistics - Trip Amounts            
    PTRV_SREC                      Trip Statistics - Receipts                
    PTRV_TRIP_CHAIN                Table of all Trip Destinations f. Processi
    PTRV_TRIP_DELETE               Trips Deleted in R/3 For Offline Travel Ma
    SFLTRIPBOK                     Individual Flight Bookings for a Flight Tr
    T702N                          Trip Provision Variants

  • How to find table name in ebs

    Hello,
    ebs r12 12.1.1
    os oul5x64
    i am looking for a table name in the database to compare the setup between 2 systems.
    when connect as sysadmin --->Concurrent --->manager --->define-- select Standard manager -->select Specialization Rules--
    in this form there are columns
    Exclude Type Application Name
    Exclude Program Master Schedule/MRP Copy MPS Plan
    how can i find the table that stores the Application and Name above.
    Thanks in advance.

    Hi,
    if I understand your requirement, you want to find the application names, which are stored in
    FND_APPLICATION and FND_APPLICATION_TL tables.
    you need to join these tables to the APPLICATION_ID column in FND_CONCURRENT_QUEUES_VL to get application_name.
    Tip: one way to confirm if you are checking correct table is to query for same data on the Form and in the database and comparing.
    Regards
    Imran

  • How to find table name(s) in a dynamic query

    In one of our (9iAS PORTAL)applications, any user can able to run their query statment and get output. All queries will be executed as dynamic SQL thru' a common shema/user who has 'SELECT' privilege on all tables but all users don't have this privilege on all tables. Now, before executing any query I need to find out what are the table name(s) used in this query to check the privilege for the respective user. How do I extract all table names being used in a dynamic query?.
    Thanks
    -Krishnamurthy

    I guess that his users log in to application first, then application uses one account to log in to database, so application are not direct database user since all users share the same account to database. If so, when a user lgins in, you may write it down from application to a database audit table, and you need to write down the dynamic query to the database audit table too, then you may query that audit table to find out. up to here, it looks that your application has to do more to assign what role to a user running the application, since database does not know what user is assessing it.

  • Table name in which approver details are stored-Workflow

    Hi ,
    Can any one tell me the table name of approver is stored and theire levels...
    Regards,
    Veera

    Do you know which table maintains approver details of PO?

  • Want know a table name in which material movement field exits

    hi,
    if any know the table name which contains "material movement" field and  ("vendor number" or any vendor related field)

    Material movements are in tables MSEG and MKPF.
    Regards,
    Rich Heilman

Maybe you are looking for