Same trigger for several tables

Is it possible?
I want to modify the PK that is trying to be inserted with sys_guid() value. I have more or less 300 tables in the database so generating 300 triggers like
create or replace trigger godtrigger
before insert
on X
FOR EACH ROW BEGIN
:NEW.id := sys_guid();
END;
does not appeal. I would like something like
before insert
on X,Y....Z
Is this somehow achievable somehow?
Thanks in advance

But you can generate these triggers with dynamic SQL
select table_name from all_tables where .....
and change dynamically name of tables and triggers respectively.Could you work out the solution a little more? I haven't used "dynamic SQL" before.
But ! The idea to use sys_guid() as PK is VERY BAD ! Why so? I need a quick way to generate the ids in a distributed db. I tought this would be better than sequences

Similar Messages

  • One trigger for Multiple tables

    Hi all,
    I want write a trigger for mutiple tables.
    For Example,
    In database schema,some user update one table.I want to capture what the table and capture old value and new value.
    the above example for all insert and delete also.
    Regards
    Fame

    Hi, Fame,
    Sorry, a trigger only works on one table, so you need a separate trigger on each separate table.
    All of those triggers can call a common procedure.
    If you'd like to give a more detailed description of what you want to do, using two or three tables, then someone can give you more detailed instructions on how to do it.
    Always say which version of Oracle you're using.

  • Creation of sequence and trigger for each table!!!!!!!1

    Hi
    I am new to trigger and Sequence field. In one of my database we have many tables with fields for specifing ID numbers. Iam planning to insert the ID field with help of a Sequence and trigger...that trigger fires by adding the sequence value from the dual table. Now the point is here we r having around *60* table with ID field. And i am planning use the above process for each table by creating sequences and trigger for each table.
    Will this affects the performance of database.
    Is there any other option other than the above process, I mean other than creating sequences and trigger for each table.
    PLzz help to resolve this issuee......
    Shiyas
    Edited by: user13170361 on Jun 7, 2010 12:37 AM

    Tiger, I didn't mind about your comment, but the point is try to use
    select NVL(max(a) + 1,1) into i from p1_temp;This line in your trigger code and see what is happening. The problem is with your trigger. You are using group by function and you will not get no_data_found !
    For more help, this is some modification of your code.
    SQL> create table p1_temp (a number(10) primary key, b number(10));
    Table created.
    SQL> create or replace trigger trg_p1_temp
      2  before insert on p1_temp for each row
      3  declare
      4  i number(10);
      5  begin
      6  begin
      7  select NVL(max(a) + 1,1) into i from p1_temp;
      8  exception
      9  when no_data_found then
    10  i := 1;
    11  end;
    12  :new.a := i;
    13  end;
    14  /
    Trigger created.
    SQL> insert into p1_temp(b) values (1);
    1 row created.
    SQL> insert into p1_temp(b) values (2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from p1_temp;
             A          B
             1          1
             2          2
    SQL> Edited by: Saubhik on Jun 7, 2010 2:30 AM

  • My sons iPod touch stopped working, it won't charge in a docking station and the computer/itunes won't recognize it when connected.  We have tried holding the power and home button at the same time for several seconds, and the screen still stays black

    My sons iPod touch stopped working, it won't charge in a docking station and the computer/itunes won't recognize it when connected.  We have tried holding the power and home button at the same time for several seconds, and the screen still stays black.  Thanks!

    Hello skdog I possibly think your ipod touch is black because it has not charged. If your dock is broken it might just mean the dock will be broken and so might be the USB port. You should see an Apple shop nearby and hand it over and see what they can do. I hope this information works!

  • Single Trigger for muliple tables

    Hi All,
    I have one requirement to create a trigger to populate a table (X) based on the any insert or update on few tables (A,B,C,D,E,F).
    Do I need to create trigger for each table ??. any idea of using all tables in one trigger.

    Hi,
    this is not possible.
    but you can use multiple trigger on single table
    if you can use view, then you can use INSTEAD OF Trigger on view
    for example
    CREATE OR REPLACE VIEW manager_info AS
        SELECT e.ename, e.empno, d.dept_type, d.deptno, p.prj_level,
               p.projno
            FROM   Emp_tab e, Dept_tab d, Project_tab p
            WHERE  e.empno =  d.mgr_no
            AND    d.deptno = p.resp_dept;
    CREATE OR REPLACE TRIGGER manager_info_insert
    INSTEAD OF INSERT ON manager_info
    REFERENCING NEW AS n                 -- new manager information
    FOR EACH ROW
    DECLARE
       rowcnt number;
    BEGIN
       SELECT COUNT(*) INTO rowcnt FROM Emp_tab WHERE empno = :n.empno;
       IF rowcnt = 0  THEN
           INSERT INTO Emp_tab (empno,ename) VALUES (:n.empno, :n.ename);
       ELSE
          UPDATE Emp_tab SET Emp_tab.ename = :n.ename
             WHERE Emp_tab.empno = :n.empno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Dept_tab WHERE deptno = :n.deptno;
       IF rowcnt = 0 THEN
          INSERT INTO Dept_tab (deptno, dept_type)
             VALUES(:n.deptno, :n.dept_type);
       ELSE
          UPDATE Dept_tab SET Dept_tab.dept_type = :n.dept_type
             WHERE Dept_tab.deptno = :n.deptno;
       END IF;
       SELECT COUNT(*) INTO rowcnt FROM Project_tab
          WHERE Project_tab.projno = :n.projno;
       IF rowcnt = 0 THEN
          INSERT INTO Project_tab (projno, prj_level)
             VALUES(:n.projno, :n.prj_level);
       ELSE
          UPDATE Project_tab SET Project_tab.prj_level = :n.prj_level
             WHERE Project_tab.projno = :n.projno;
       END IF;
    END;see more : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm
    Edited by: Mahir M. Quluzade on Oct 12, 2011 9:23 AM

  • Same AUC for several invoices

    Hello guys,
    My client wants to use the same AUC several time across years (for different final assets):
    Form me,  the inconvenient of this procedure is that:
    - The more items have to settled the more difficult it is to define correctly the link between the AUC transaction and the final asset to be impacted (it is easier to create one AUC per Invoice or PO),
    - When the AUC is fully settled, the deactivation date is updated and should be manually modified if subsequence transactions should be recorded for this AUCu2026
    Do you have any other argument saying that the same AUC should not be used several times?
    What is the SAP best practice regarding the link between the AuC and the Final asset?
    Thank you in advance for your help,
    Best regards,
    Pascal

    When you use PS for AUC you can use the following transactions:
    CJ70     Line item distribution
    CJIC     Line item distribution  (same as CJ70)
    In there you sellect you posting (s) and setlle it from there to the final asset.

  • Sharing the same JTableHeader for several JTables

    Hello,
    I would like to know if it is possible to have a JTableHeader common to several JTables.
    For instance the resizing of a column in the common header should resize the corresponding column for all the JTables.
    Thanks for your help !
    Joel

    Except there's a bug introduced in 1.4x (1.3 works fine) that disables resizing of the columns in all the tables except the last into which the shared columnModel is set.
    To workaround, subclass JTable and override columnMarginChanged:
        JTable table = new JTable()
        // including the following will fix the bug
          public void columnMarginChanged(ChangeEvent e) {
            if (isEditing()) {
              removeEditor();
            TableColumn resizingColumn = null;
            if (tableHeader != null) {
              resizingColumn = tableHeader.getResizingColumn();
            if (resizingColumn != null) {
              if (autoResizeMode == AUTO_RESIZE_OFF) {
                resizingColumn.setPreferredWidth(resizingColumn.getWidth());
              } else {    // this else block is missing in jdk1.4 as compared to 1.3
                doLayout();
                repaint();
                return;
            resizeAndRepaint();
          private int viewIndexForColumn(TableColumn aColumn) {
            TableColumnModel cm = getColumnModel();
            for (int column = 0; column < cm.getColumnCount(); column++) {
              if (cm.getColumn(column) == aColumn) {
                return column;
            return -1;
        };Greetings
    Jeanette

  • How is it possible to make sure that LV uses the same thread for several threadsafe DLL calls?

    Hello,
    i have a thread safe DLL and most functions are called from serveral threads from the LV apllication without problems.
    In case of an error i have to call an error handler function in this DLL (like WinAPI: GetLastError()) from the same thread which has called the function that failed before.
    I can't use the user interface execution because some functions need a long execution time and i don't want to balk the user interface.
    All other executions than the user interface execution have more than one thread and in most cases the DLL function calls were executed from different threads - so the error handling doesn't work...
    Any idea?
    Thanks for your help!

    Hmmm....
    How about wrapping all of your dll calls in a single VI (or an Action Engine ) and make sure the VI's thread is NOT set for "Same as caller".
    "Threadconfig.vi" (sp?) will also let you dictate the number of threads associated with an execution system. Set your target thread for "1".
    Not sure on the above.
    Please correct me if this is wrong!
    Ben
    Message Edited by Ben on 07-19-2007 08:26 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Feature request - use same colors for joined tables

    I brought two datasets into Power Map. Both have a shared segmentation dimension (joined in Power Pivot). Power Map doesn't pay attention to the fact that the tables are joined and does not use the same series colors.  I have to manually adjust all
    the colors (~2 dozen segments) which is painful and should not be necessary. Power Map should be smart and automatically use the same colors.

    You are more likely to
    produce some effect if you post your request here:
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

  • One model for several tables

    Hello!
    I want to use one model in two tables.That's why within Model(in getModel method) I must know what table request my Model.
    How can I do that?

    Two different Table Views have data from One table in DB, but with different selection filter.
    That's why I want to use one model class with variable in it, that contain name of request TableView.

  • Can any one please send me an update trigger (pl/sql procedure) for ap tables(ap_suppliers,ap_supplier_site_all,and contacts)

    Please send an query for update trigger for those tables .
         1: ap_suppliers
         2: ap_supplier_sites_all
         3: ap_supplier_contacts.
    Thanks,
    Chaitanya.

    Hi,
    Actually ID and Data are different names in my API. Here I mentioned like that.
    Am using Oracle 10g version.
    Yes I am going to get the multiple values using this Ref Cursor. The same ref cursor is used in another API of my package.
    In this API, the user actually enters Application_id and data. API should insert/update the version_master table with the inputs. See application_id is the foriegn key for app_master table.
    The requirement is whenever they enters application_id and data, if application_id already present in the version_master table, then the data should be updated and we should get a status flag for this using Out variable(i.e. using ref cursor only we are showing the status). if the application_id is not present in the version_master table, new record should be inserted. The sequence will generate the version_id for version_master table.
    But the Merge statement is working fine for update and insert also. Problem is am unable to see the success or failure through ref cursor. I don't know how exactly I can use this.
    If data is NULL the operation should be failed. i.e. I should get Failure status here. But am not getting this.
    Please remove the comments here and then check. If I use the NVL2 function I was able to get the status flag, i.e. S or F.
    OPEN resultset_o FOR
    SELECT NVL2 (data, 'S', 'F')
    FROM version_master
    WHERE application_id = application_id_i;
    1.How the value of data being not null will determine Success of the api and how null failure
    2.If the above select statement goes in to exception when others how I will no the failure
    I have to achieve the above scenarios.
    Please advice me.

  • Trigger problem -- can't insert the same data into audit table

    Sir/Madam,
    I'm trying to use insert trigger with a 'long raw' datatype data for my audit purpose. Each time, the data of original table can be inserted correctly. While the trigger for audit table in which it contains almost the same data as original would failed. The error messages are some thing like following:
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    ORA-06512: at "CORPSEC.TI_ARCHIVE_PDF", line 9
    ORA-04088: error during execution of trigger 'CORPSEC.TI_ARCHIVE_PDF'
    If the column with 'long raw' datatype is taken out, then there is no error at all. I'm using Oracle 8i 8.1.6 for Windows NT and suspect there is bug in PL/SQL execution.
    The following are SQL text for the trigger:
    CREATE OR REPLACE TRIGGER "CORPSEC"."TI_ARCHIVE_PDF" AFTER INSERT ON "ARCHIVE_PDF" FOR EACH ROW DECLARE
    LOG_SEQ_NO NUMBER;
    BEGIN
    SELECT AUDIT_SEQ.NEXTVAL INTO LOG_SEQ_NO FROM DUAL
    insert into ad_archive_pdf (DOC_TITLE,PDF_FILENAME,CONTENT,DOC_DESC,AUDIT_REF_NO,AUDIT_DATE,AUDIT_MODE,AUDIT_BY)
    values (:new.DOC_TITLE,:new.PDF_FILENAME,:new.CONTENT,:new.DOC_DESC,LOG_SEQ_NO,sysdate,'I',:new.created_by);
    END;
    Any help on this. Thank in advance.
    Best regards,
    Ruijie

    See here for a discussion of how to incorporate LONG datatypes into triggers:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:635439::NO::F4950_P8_DISPLAYID

  • My yahoo e-mail not pushing to iPhone4, again.  Had this same problem in October for several weeks.  My kids and husband have 3 other types of smart phones, and none of them are experiencing this problems.  This has been going on for 2 weeks so far.

    My yahoo e-mail is not pushing to my iPhone4, again.  Had this same problem for several weeks in October/November 2011.  It's been a problem again for two weeks now.  My kids and husband have three other types of smart phones, and none of them have had this problem.  I'm NOT impressed.  I've seen that others in the iPhone community have also been having this problem.  Is Apple doing anything about it?

    Read this: https://discussions.apple.com/message/17333604#17333604
    It's a yahoo issue. Nothing you can do on your phone to fix it.

  • Trigger for more  than One table

    Hi,
    is it possible to create a trigger for more than one table?
    I need a trigger that fires when anyone of the users updates a special value in one of the DB tables.
    this value is in about 8 or 10 tables, or must i create a trigger for each table?
    thanx
    marcel

    You would wrap the functionality required into a packaged procedure and then have a trigger on each of these tables that simply call this packaged procedure.
    Yes, you would have one trigger per table.

  • Is it possible raise a trigger for particular user

    hi,
    i have oracle user zil,i want to write trigger for this user..
    with out writting trigger for each table .
    for ex:
    i have 2 tables in this user
    1.emp
    2.audit_log
    suppose i m inserting values into emp table at the same time insert into audit_log with action as insert,like that suppose i m updating any row in emp then insert one row into audit_log with action as modify,
    my question is is it possible to write a trigger for the user zil,not for table emp
    so i can maintain audit_log..
    pls give me a solution
    regards
    singh

    It depends upon how you are connecting to the Oracle database, if you are connecting through CITRIX then it is difficult to identify the user or the other option for you is to have a field USER in each table and pass the user name form the front end.
    To captures the changes in the table EMP and insert into the AUDIT table you may need to write a trigger in the EMP table and before you INSERT into AUDIT check the user.
    Or why dont you use AUDITING provied by Oracle.
    Thanks

Maybe you are looking for

  • Help needed in Excel Exporting

    Hi, I got a database fieldcalled category. My report is grouped on category. Category can be Agriculture or MNO or Energy. So i am getting 3 groups thats fine and the data obtained is tested to be correct. Now wen i export the report into excel. Agri

  • WRT110 no longer connects

    I can no longer connect with my WRT110.   If I plug my line direct from a cable modem to my laptop, all is fine.  On my desktop not since Charter reset the modem.  With the router and the desktop, I get in IP of 0. I have re-powered everything a hund

  • Connecting HP Laserjet 500N using ethernet cable and router

    I had my HP Laserjet 5000N connected to my wireless router via ethernet cable. It worked fine. But then I changed routers and can't remember how to reestablish the connect.  Can anyone help? Thanks

  • Error "Disk too slow"

    I record on my PB G4, with Garage Band. I run instruments to a board, then to the m-audio fast track. the files are saved on a Seagate 300GB External FireWire Drive, from which i record. I understand it is caused due to the high number of tracks with

  • How to update logic express 9.01 under lion?

    After I installed Lion on my computer I recognized that i missed to update Logic express from 9.01 to 9.1, so the old version is not able to run under Lion. If I try now to update Logic express the system tells me to update from 9.01 what is recommen