DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: Trigger question

  1. #1
    Join Date
    Jan 2003
    Location
    Maryland, USA
    Posts
    12

    Trigger question

    I create a trigger to automatically insert '-9999' into a column.
    The code is like this:

    CREATE OR REPLACE TRIGGER PERSONNEL_BSTATEMENT
    BEFORE INSERT ON L_NWS_PERSONNEL
    BEGIN
    INSERT INTO L_NWS_PERSONNEL (GREMPID_KEY)
    VALUES ('-9999');
    END PERSONNEL_BSTATEMENT;

    When I load data to fire this trigger, the error message comes out like this:

    ORA-00036 Maximum number of recursive SQL level (50) exceeded.

    I go to Oracle 9i online documentation. It only says to delete the trigger. Please help to tell me the reason. Thanks.

    Frank
    Frank

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    you understand why this is happening, right? The trigger detects an insert into the table -> the trigger inserts another row into the table -> the trigger detects the new row -> the trigger inserts another row etc.

    This is presumably not what you wanted, so what do you really want to happen?
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Maybe something like that?
    Code:
    CREATE OR REPLACE TRIGGER PERSONNEL_BSTATEMENT
    BEFORE INSERT ON L_NWS_PERSONNEL
    for each row
    BEGIN
      :NEW.grempid_key := '-9999';
    END PERSONNEL_BSTATEMENT;
    P.S. As slimdave said, it is not very clear what you actualy want to do, so the above is only my guessing...
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  4. #4
    Join Date
    Jan 2003
    Location
    Maryland, USA
    Posts
    12

    Response

    jmodic

    Thanks for your input. What I want to do is, I only want to insert one row of -9999 into that table. Then I load data into Fact_table, it will work as a PK for the FK in Dimension_table.
    Frank

  5. #5
    Join Date
    May 2002
    Posts
    108

    -9999 for every insert?!

    Frank

    Do u need to insert -9999 every time a new record is inserted into the table?

    - Nandu
    Never give up !

    Nanda Kumar - Vellore

  6. #6
    Join Date
    Jan 2003
    Location
    Maryland, USA
    Posts
    12
    Nandu:

    No. I only need to insert -9999 into the table before inserting or updating the table. I only need to insert one row into the table. Thanks.

    Frank
    Frank

  7. #7
    Join Date
    Jan 2000
    Location
    Chester, England.
    Posts
    818
    Not sure what you mean. Insert the key value ONCE into the table - into 1 single row?
    So what about subsequent rows?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width