Insert Audit Trigger Problems

I am almost entirely new to triggers. I have written this trigger inside the .sql file with the rest of the database (inserts, views, sequences and so on):
create or replace trigger t_customer_changes
after insert on customer
for each row
begin
        if inserting then
                insert into CUSTOMER_AUDIT
                        (customer_id, name, audit_date)
                values
                        (:new.customer_id, :new.name, sysdate);
        end if;
end;
/I get a number of errors. Immediarely after the trigger i get:
Warning: Trigger created with compilation errors.And then on almost every insert statement on most tables i get this:
ORA-04098: trigger 'OC0001.T_CUSTOMER_CHANGES' is invalid and failed re-validationThe customers table is created like this:
customer_id     VARCHAR2(2),
name VARCHAR2(20),
PRIMARY KEY(customer_id)Any ideas?

Does the table customer_audit exist in the same schema as customer? If not, the owner of customer will need insert on customer_audit granted directly to them, and will need to qualify the reference to customer_audit with the owner like:
INSERT INTO owner.customer_audit ... [pre]
HTH
John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to activate JDBC debugging for SPRING 3.1? Oracle trigger problems ...

    Hi,
    I have some trigger problems. I created a trigger to update a certain column each time a new record is inserted or an existent record is updated. I use Oracle 10g. If I create the trigger and execute an insert query via the XE client everything works fine. However, when I use a spring 3.1 setup with Hibernate and OJDBC driver, I get an
    java.sql.SQLException: ORA-04098: trigger 'LOCALUSER_PROP_TRIG' is invalid and failed re-validation
    And if I execute a show error trigger query I get an invalid SQL query error.
    I can easily activate Hibernate debugging and I can see that the prepared statement by Hibernate is just fine, but I was wondering if I could see the full sql sent by the JDBC driver to the server. Maybe seeing the actual query sent to the server would provide new insight of what could be wrong in the Hibernate setup. Does any one what could be wrong and eventually how could setup jdbc to output debug info? Thanks a lot,
    Cristian

    Which platform is the database running on ??
    Other things you should check -
    when debugging the EJB, JDev
    3.1 looks through your IIOP connections to find the one to use.
    Make sure that the IIOP connection that JDev is using for the debugging matches the IIOP connection that the EJB client application is using.
    raghu
    null

  • Mutating DB Trigger Problem

    Hello all, i have a ' Mutating DB Trigger Problem' for the following Trigger :
    =============================================
    CREATE OR REPLACE TRIGGER ASSIUT.EMP_ATTENDANCEE_MONA
    AFTER INSERT
    ON ASSIUT.ACCESSLOG
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    V_COUNT CHAR(2);
    --V_COUNT_OUT CHAR(2);
    BEGIN
    IF :NEW.INOUT = 'IN' THEN
        INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT ,TIME_IN ,TIME_OUT)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
                 NULL,
                 TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),      -- TIME_IN
                 NULL );      -- TIME_OUT
                     SELECT COUNT(employeeid )
                     INTO V_COUNT
                    FROM ACCESSLOG
                    WHERE employeeid =:NEW.employeeid
                    AND LOGDATE =:NEW.LOGDATE
                    AND  LOGTIME  =:NEW.LOGTIME
                    AND INOUT ='IN';
                    IF V_COUNT > 0 THEN
         INSERT INTO ATT_INCOMPLETE  (  EMP_ID , ATT_DATE , ATT_TIME ,  ATT_FLAG)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
          TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),        -- TIME_IN
          1); -- check in
          END IF;
    ELSIF :NEW.INOUT = 'OUT' THEN
        UPDATE  EMP_ATTENDANCEE
        SET           DATE_OUT   =  TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
                      TIME_OUT   =   TO_DATE(:NEW.LOGTIME,'HH24:MI:SS') -- TIME_OUT
        WHERE   EMP_ID           =   TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
        AND DATE_IN =  (SELECT MAX (DATE_IN )
                        FROM EMP_ATTENDANCEE
                        WHERE EMP_ID = EMP_ID
                        AND   DATE_OUT IS NULL
                        AND   TIME_OUT IS NULL ) ;
                  SELECT COUNT(employeeid )
                     INTO V_COUNT
                    FROM ACCESSLOG
                    WHERE employeeid =:NEW.employeeid
                    AND LOGDATE =:NEW.LOGDATE
                    AND  LOGTIME  =:NEW.LOGTIME
                    AND INOUT ='OUT';
                    IF V_COUNT > 0 THEN
    INSERT INTO ATT_INCOMPLETE  (  EMP_ID , ATT_DATE , ATT_TIME ,  ATT_FLAG)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
          TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),        -- TIME_IN
         0); -- check in
    END IF;
    END IF;
      EXCEPTION
       WHEN OTHERS  THEN RAISE;
    END EMP_ATTENDANCEE_MONA ;The above Trigger generates the following error:
    ORA-04091: table ASSIUT.ACCESSLOG is mutating, trigger/function may not see it
    ORA-06512: at "ASSIUT.EMP_ATTENDANCEE_MONA'", line 65
    ORA-04088: error during execution of trigger 'ASSIUT.EMP_ATTENDANCEE_MONA'i want an easy and a straight forward solution to this problem which occured on selecting or manipulating from the same table i triggered it.
    Best regards,
    Abdetu..

    Create a package
    CREATE OR REPLACE PACKAGE PK_TRIGGER IS
      PROCEDURE PR_BS;
      PROCEDURE PR_ARIU(i_vcType IN TABLE.COLUM%TYPE, i_nEmpId TABLE.COLUM%TYPE, i_vcLogDate IN TABLE.COLUMN%TYPE, i_vcLogTime IN TABLE.COLUMN%TYPE);
      PROCEDURE PR_AS;
    END;
    CREATE OR REPLACE PACKAGE BODY IS
      TYPE tData IS RECORD (
        vcType     TABLE.COLUMN%TYPE,
        nEmpid     TABLE.COLUMN%TYPE,
        vcLogDate TABLE.COLUMN%TYPE,
        vcLogTime TABLE.COLUMN%TYPE
      TYPE tDataList IS TABLE OF tData INDEX BY BINARY_INTEGER;
      lData tData;
      PROCEDURE PR_BS IS
      BEGIN
        lData.DELETE;
      END;
      PROCEDURE PR_ARIU(i_vcType IN TABLE.COLUM%TYPE, i_nEmpId TABLE.COLUM%TYPE, i_vcLogDate IN TABLE.COLUMN%TYPE, i_vcLogTime IN TABLE.COLUMN%TYPE) IS
        iPos PLS_INTEGER:=lData.COUNT+1;
      BEGIN
        lData(iPos).vcType:=i_vcType;
        lData(iPos).nEmpId:=i_nEmpId;
        lData(iPos).vcLogDate:=i_vcLogDate;
        lData(iPos).vcLogTime:=i_vcLogTime;
      END;
      PROCEDURE PR_AS IS
        CURSOR crCheck(i_nIdentnum IN NUMBER) IS
          SELECT 1
            FROM <YOURTABLE> A,
                 <YOURTABLE> B
           WHERE A.IDEN_NUM=B.IDENT_NUM
             AND (   A.BEGIN_DATE BETWEEN B.BEGIN_DATE AND B.END_DATE
                  OR A.END_DATE BETWEEN B.BEGIN_DATE AND B.END_DATE
        iPos PLS_INTEGER;
        nDummy NUMBER;
      BEGIN
        iPos:=lData.FIRST;
        LOOP
          EXIT WHEN iPos IS NULL;
          -- Do whatever you want with the data in the record
          -- Process next record
          iPos:=lIds.NEXT(iPos);
        END LOOP;
        lIds.DELETE;
      END;
    END;replace TABLE.COLUM%TYPE with appropiate table and column
    Now create a
    - Before Statement trigger on your table calling PK_TRIGGER.PR_BS;
    - After Insert on Update for each row Trigger calling PK_TRIGGER.PR_ARIU(...values...);
    - After Statement trigger on your table calling PK_TRIGGER.PR_AS;
    Hope the code compiles for i have no database at hand.
    Andreas

  • Nokia C7 Insert Sim Card Problem

    Hi,
    I got my c7  and there are two points I need to discuss
    1) after 2 days I have faced  insert sim card problem , Please let me know if this can be fixed , how it can be fix or should I contact Nokia SC 
    has anybody faced this problem before or it it just a clinch in Nokia C7 and needs a software update.
    Here is my Nokia SW Version
    Software Version : 012.004
    Custom  Version :  012.004.C02.01
    Type                       :  RM-675
    2) Phone Heat ups 
       After talking around 20 mins on phone , phone heats up , is this normal with smart phones ?
    Thanks in Advance.

    hi majiclover
    1) Spekar phone is bit/very Dull
    2) normal spekar is bit "ok"
    I would prefer Nokia 2626 as it has Very good Sound normal and spekar phone.
    Free advice : you might want to give second thought.!!!
    my porblem STILL persists.   Heat problem I dont know but it does when
    1) Charging
    2) Speaking for more then 10-15 min.( NOT Expected from New phone)
    and it heats up and heats up ................you can not keep it near your ear for long.

  • 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

  • Mutating Error problem using audit trigger for UPDATE

    I need to add 4 columns to all of my tables named:
    INSERT_BY
    INSERT_DATA
    UPDATE_BY
    UPDATE_DATE
    I intend these to act as "inserted" and "last updated" audit trails within the table, as opposed to creating a new table and storing the audit information there. The insert columns appear to be easy, as I can just use a DEFAULT clause within the definition of the table. However when I attempted to write a (my first) trigger then I run into problems with mutating tables. Presumebly because I am attempting to change the table while the trigger is referencing it.
    create or replace trigger test_audit
    after update on dictionary
    begin
    update dictionary
    set update_by = user, update_date = sysdate
    where entity_id = :old.entity_id;
    end;
    I thought I could maybe get around this by calling a procedure from inside the trigger. Something like:
    create or replace procedure test_audit(vColumn in varchar2, vData in varchar2, vTable in varchar2) is
    -- vTable is table name
    -- vColumn is PK of table
    -- vData is value of PK in current row
    begin
    update vTable
    set update_by = user, update_date = sysdate
    where vColumn = vData;
    commit;
    end test_audit;
    However I cannot use variable for table names. Will this mean I have to create a procedure for each table/trigger? Is there a way to reference the table name as a variable and keep this a generic procedure? Or is there an easier way to record the auditing UPDATE information for each changed row within the original table?
    Many thanks in advance......

    Will
    this mean I have to create a procedure for each
    table/trigger? I think you've answered that question already.
    Is there a way to reference the table
    name as a variable and keep this a generic procedure?Not that I'm aware of.
    Or is there an easier way to record the auditing
    UPDATE information for each changed row within the
    original table?Well, there's the AUDIT feature.
    C.

  • After insert trigger problem

    I am trying to write a trigger which will update a date col after every insert////
    CREATE OR REPLACE TRIGGER PS1.XX_CDATE
    AFTER INSERT ON ps1.COMMNPLANBUDGET
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    declare PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    update ps1.COMMNPLANBUDGET set CREATION_DATE=sysdate where PROJECTID = :new.PROJECTID;
    commit;
    END XX_CDATE;
    For the same i have written the above code, it created successfully but when i am inserting a record the date col is not getting updated. Please let me know where i have done wrong. Thanks in advance

    Hello
    You should not use autonomous transactions in a trigger. Do not do it, and if anyone tells you to use autonomous transactions in a trigger to avoid mutating table exceptiosn, you should instruct them to put their hands in a toaster, switch it on maximum and insist they keep them there until the timer reaches zero.
    Anyway, if the primary key on this table is project ID, you don't need to go to these lengths. You can simply
    CREATE OR REPLACE TRIGGER PS1.XX_CDATE
    BEFORE INSERT ON ps1.COMMNPLANBUDGET
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    BEGIN
        :NEW.creation_date := sysdate;
    END XX_CDATE;If project_id is not the primary key, why would you update the creation date for all rows attached to the project id?
    David
    Edited by: Bravid on Sep 22, 2011 9:29 AM
    Oops, after reading Karthik's post, I realised I left the AFTER insert in the trigger spec. Updated it to BEFORE.

  • Help with Oracle Table Audit Trigger

    Hi Guys,
    Need some help with the design of a trigger please. I have created one standard audit table where all sensitive data will be audited/inserted. The idea is to insert the column name and the old and new values here, dont want to maintain an audit table for each and every table there is, reporting would be a nightmare.
    Trying to fetch all the column names from sys objects then looping through each and inserting the new and old values for them into the audit table. Everything else is fine apart from the actual :old and :new value inserts. The column name is coming from a variable in a cursor and this is where I seem to be failing.
    Can anyone help please? What is the correct syntax to use?
    CREATE OR REPLACE TRIGGER commission_update
        AFTER UPDATE
            ON commission
            FOR EACH ROW
    DECLARE
            v_username varchar2(10);
              v_column varchar2(20);
              -- Get Table Columns
              cursor table_column is
                      select c.name
                      from  sys.col$ c, sys.obj$ t
                      where t.obj# = c.obj#
                      and   t.type# in (2, 3, 4) 
                      and   bitand(c.property, 32) = 0 /* not hidden column */
                      and t.name = 'COMMISSION';
        BEGIN
            -- Find username of person performing UPDATE into table
            SELECT user
         INTO v_username
            FROM dual;
              open table_column;
                    loop
                          fetch table_column
                         into v_column;                    
                         EXIT WHEN table_column%NOTFOUND;
                                 -- Insert record into audit_record
                             INSERT INTO audit_record
                                  ( aud_code,
                                      aud_ban_code,
                                      aud_user,
                                      aud_table,
                                  aud_column,
                                   aud_old_val,
                                   aud_new_val,
                                   aud_date )
                                VALUES
                                  ( xaudit_record.nextval,
                                      :old.com_ban_code,
                                      v_username,
                                      'COMMISSION',
                                   v_column,
                                   :old.v_column, /* problem here!!!!!!! */
                                   :new.v_column, /* problem here!!!!!!! */
                                   sysdate );
                    end loop;
              close table_column;
        END;
    /

    What does auditing mean in the financial environment? "An audit is a professional, independent examination of a company's financial statements and accounting documents according to generally accepted accounting principles."
    What does it mean in database terms? Surely, the basic definition would be the same, ito of a proper independent examination of changes in the database according to accepted principles?
    And just how does a trigger live up to that? When it is fully dependent on being enabled for that transaction in order to examine it? It is trivial to disable a trigger, make changes, and re-enable it.
    So what happens to your "auditing" then?
    Do you really think that a trigger suffices as a means to audit changes in a table? And if so, what logic and reasoning do you use to discard Oracle's auditing features that are built into the core of the database?

  • Trigger Problem, need help in 8i

    SQL> Create table a (sno char(3), kkk varchar2(30));
    SQL> Create or replace trigger T$a before insert on a
    for each row
    begin
    if :new.sno = 'FFF' then select nvl(max(sno),0)+1 into :new.sno from a;
    end;
    SQL> insert into a select 'FFF', cont_no from gcmis.cont_rent;
    insert into a select 'FFF', cont_no from gcmis.cont_rent
    ERROR at line 1:
    ORA-04091: table TR.A is mutating, trigger/function may not see it
    ORA-06512: at "TR.T$A", line 2
    ORA-04088: error during execution of trigger 'TR.T$A'
    Why & How?

    It happens because you read the table that was in the middle of being modified by your trigger...
    The only way to proceed is to rewrite your statement so it does not read the table.
    For example, you can store the maxvalue of your field in another table...
    But don't forget that if sno is a unique key, you'll probably have problems when working with a mutli-users app...
    SQL> Create table a (sno char(3), kkk varchar2(30));
    SQL> Create or replace trigger T$a before insert on a
    for each row
    begin
    if :new.sno = 'FFF' then select nvl(max(sno),0)+1 into :new.sno from a;
    end;
    SQL> insert into a select 'FFF', cont_no from gcmis.cont_rent;
    insert into a select 'FFF', cont_no from gcmis.cont_rent
    ERROR at line 1:
    ORA-04091: table TR.A is mutating, trigger/function may not see it
    ORA-06512: at "TR.T$A", line 2
    ORA-04088: error during execution of trigger 'TR.T$A'
    Why & How?

  • Enterprise Manager 10g & trigger problem

    Hi.
    Trying to create a trigger using Enterprise manager 10g WEB Console and trigger creating "wizard" without success.
    Example: I've added a simple trigger using SQL+ (this works ockey):
    CREATE OR REPLACE TRIGGER "SRECKO".TESTNA_TRIG BEFORE
    INSERT ON "SRECKO"."TESTNA" REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW begin
    select testna_seq.nextval into :new.kljuc from dual;
    end;
    If I use Enterprise's Manager feature and I construct this trigger with (General/Event/Advanced) tabs it just doesn't work. I allways get the same SQL Error (missing IN or OUT parameters -> PreparedStatement bug ???).
    Has anybody had any similar experiences ?
    matev¾

    I am having the same problem. Unfortunately, it looks like no one else is or no one else has an answer. I will check back again later. Right now I am going to try and google and answer. Hope someone responds here.

  • Trigger problem on Sql Server with linked server to Oracle

    Hi All,
    I have a simple insert trigger on Sql Server 2005, it uses linked server to Oracle.
    like that ;
    USE [YTM08]
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ANSI_NULLS ON
    go
    ANSI_WARNINGS ON
    CEATE TRIGGER [dbo].[YTM_TBLSTSABIT_I]
    ON [dbo].[TBLSTSABIT] FOR INSERT
    AS
    BEGIN
    INSERT INTO YTM_ORACLE..SECTOR.STOCKS
    stock_name,
    stock_code,
    insert_date
    SELECT
    SBT.STOCKNAME,
    SBT.STOCKCODE,
    GETDATE()
    FROM INSERTED SBT
    END
    The YTM_ORACLE is a linked server and it's provider is OraOLEDB.Oracle.
    Trigger does not works for that linked server but other triggers for local
    sql server works fine...
    I get this error from sql server
    'Heterogeneous queries require the ANSI_NULLS and
    ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.'
    Does someone know how to solve this issue the right way?
    Thanks in advance.
    Thanks !
    Adam

    Hi Lars,
      Thanks for the data. I've already read this note and configure all this parameters. But when I'm executing the Create Source System in the BI system the process dies.
      If I look into the logs I see this:
    M  call semaphore clean-up function ...
    M  ***LOG Q0E=> DpSigGenHandler, Exception (c06d007e) [dpnttool.c   432]
      That's the reason why I start guessing about other possible problem.
    Regards

  • SP in delete/insert/modify trigger

    I have created a trigger which sends a notification email on deletes.inserts, or updates on a particular table.  Trigger works great.  While testing, I did a delete all - and sure enough the trigger fired on every row that was deleted and I got over 6k emails, LOL!!!  So I am thinking have this trigger call a stored proc, which then keeps up with an audit table with sysdatetime/row/count or something.  If number of rows deletetd within a certain timeframe (10seconds?) exceeds 5 then don't send any more emails.  Does this sound feasible or is there a better way?  Thanks!

    I have created a trigger which sends a notification email on deletes.inserts, or updates on a particular table.  Trigger works great
    Then you must want emails to be sent even if those DML operations fail or get rolled back. Is that true?
    If a user does the following do you really want email notifications sent?
    INSERT INTO myTable . . .;
    ROLLBACK;
    Triggers are non-transactional. They do NOT know if the work they do will ever be committed or not. Any work that a trigger does could be rolled back by Oracle or by the user.
    Unless you want email notifications sent even if that DML 'never happens', because it gets rolled back, triggers are the wrong method to use.

  • ORA-01008 - not all variable bounfd when trying to insert into trigger

    Hi,
    Uisng Oraclle 11.2.0.3 and trying insert into table on remote schema.
    Tracked problem down to one column - the parent_num..
    Offending code
    a.mult_parent_num = ( select   nvl(MGrp_num, 0)
                                from     [email protected]
                                --where   MGrp_PARENT_num is not null
                                --and
                                where substr(upper(MGrp_DESCRIPTION), 2) = (select MULT_NAME
                                                                   from por_multiple p
                                                                   where p.mult_link_multiple_code = B.MULT_LINK_MULTIPLE_num)Complete truigger
    create or replace trigger POR_TRG_POP_IKNOW_MULTIPLE
    after INSERT OR UPDATE or delete   on por_MULTIPLE
    for each row
    -- tO ENSURE I-KNOW KEPT UP-TO-DATE WITH HOMIS MULTIPLE
    -- delib not delet form i-know as if has been used by customer cannot delete
    -- due to referential inetgrity constraints in i-know
    declare
    begin
    -- ensure if updating record one of attributes interested in for ho_issues_stg changed
       IF INSERTING OR UPDATING
       THEN
          MERGE INTO [email protected] a
          USING
           select
           :NEW.MULT_ANMW_MULTIPLE_CODE MULT_ANMW_MULTIPLE_CODE,
           :new.MULT_AUTH_REQUIRED MULT_AUTH_REQUIRED,
           :new.MULT_JMW_MULTIPLE_TYPE_CODE MULT_JMW_MULTIPLE_TYPE_CODE,
           :new.MULT_LINK_MULTIPLE_CODE MULT_LINK_MULTIPLE_num,
           :new.MULT_MULTIPLE_CODE MULT_MULTIPLE_NUM,
           :new.MULT_NAME MULT_NAME,
           :new.MULT_PROM_AUTH_REQUIRED MULT_PROM_AUTH_REQUIRED,
           :new.MULT_SELECTED_MULTIPLE MULT_SELECTED_MULTIPLE,
               'Y' MULT_active_flag,
           nvl(:new.MULT_JMW_MULTIPLE_TYPE_CODE, 0) MULT_CHANNEL_NUM--,
          -- :new.MULT_LINK_MULTIPLE_CODE MULT_PARENT_NUM
           from dual
           ) b
        on
           a.mult_multiple_NUM = b.MULT_MULTIPLE_NUM
    when matched THEN update set
           A.MULT_ANMW_MULTIPLE_CODE = B.MULT_ANMW_MULTIPLE_CODE ,
           A.MULT_AUTH_REQUIRED = B.MULT_AUTH_REQUIRED,
           A.MULT_JMW_MULTIPLE_TYPE_CODE = B.MULT_JMW_MULTIPLE_TYPE_CODE ,
           A.MULT_LINK_MULTIPLE_num = B.MULT_LINK_MULTIPLE_num,
           A.MULT_NAME =B.MULT_NAME,
           A.MULT_PROM_AUTH_REQUIRED=B.MULT_PROM_AUTH_REQUIRED,
           A.MULT_SELECTED_MULTIPLe=B.MULT_SELECTED_MULTIPLE,
               A.MULT_ACTIVE_FLAG = B.MULT_ACTIVE_FLAG,
           A.MULT_CHANNEL_NUM= B.MULT_CHANNEL_NUM
           a.mult_parent_num = ( select   nvl(MGrp_num, 0)
                                from     [email protected]
                                --where   MGrp_PARENT_num is not null
                                --and
                                where substr(upper(MGrp_DESCRIPTION), 2) = (select MULT_NAME
                                                                   from por_multiple p
                                                                   where p.mult_link_multiple_code = B.MULT_LINK_MULTIPLE_num)
    when not matched
    then insert
    A.MULT_ANMW_MULTIPLE_CODE,
           A.MULT_AUTH_REQUIRED,
           A.MULT_JMW_MULTIPLE_TYPE_CODE,
           A.MULT_LINK_MULTIPLE_NUM,
           A.MULT_MULTIPLE_NUM,
           A.MULT_NAME,
           a.MULT_PROM_AUTH_REQUIRED,
           a.MULT_SELECTED_MULTIPLE,
           -- NEW FIELDS ON I-KNOW
           a.MULT_ACTIVE_FLAG,
            a.MULT_CHANNEL_NUM,
             a.MULT_PARENT_NUM
    values
           b.MULT_ANMW_MULTIPLE_CODE,
           b.MULT_AUTH_REQUIRED,
           b.MULT_JMW_MULTIPLE_TYPE_CODE,
           b.MULT_LINK_MULTIPLE_NUM,
           b.MULT_MULTIPLE_NUM,
           b.MULT_NAME,
           b.MULT_PROM_AUTH_REQUIRED,
           b.MULT_SELECTED_MULTIPLE,
           -- NEW FIELDS ON I-KNOW
           b.MULT_ACTIVE_FLAG,
            b.MULT_CHANNEL_NUM,
         --   711-- parent to have parent_num group name of link multiple code
           ( select   nvl(MGrp_num, 0)
              from      [email protected]
                     --where   MGrp_PARENT_num is not null
                     --and
                       where   substr(upper(MGrp_DESCRIPTION), 2) = (select MULT_NAME
                                                                   from por_multiple p
                                                                   where p.mult_link_multiple_code = B.MULT_LINK_MULTIPLE_num)
    update   [email protected]
    set
      MULT_PARENT_num =   ( select   nvl(MGrp_num, 0)
              from     bidsaMULTIPLE_GROUPS
                     where   MGrp_PARENT_num is not null
                     and     substr(upper(MGrp_DESCRIPTION), 2) = MULT_NAME
          MULT_CHANNEL_num = nvl(MULT_JMW_MULTIPLE_TYPE_CODE, 0),
          MULT_ACTIVE_FLAG = 'Y'
    where
      MULT_PARENT_num is null;
    else
         update [email protected] p
         set  mult_active_flag = 'N'
         where  p.mult_multiple_num = :old.mult_multiple_code;
    END IF;
    EXCEPTION
         WHEN OTHERS THEN
            RAISE_APPLICATION_ERROR(-20010,'Error when writing to i-know multiple '||SQLERRM||' '||SQLCODE);
    END POR_TRG_POP_IKNOW_MULTIPLE;What am I doing wrong?

    Definitions bleow.
    Performanve fine - source table rarelyy changed - a temporary solution until the source system replaced with desination system.
    Error:
    Error when writing to multiple (sourec table) ORA-01008 - not all variables bound ORA-02063 - preceding line form bisapprd.
    - 1008 error during execution of trigger
    Source table upon which trigger acting
    -- Create table
    create table POR_MULTIPLE
      mult_multiple_code          NUMBER(4) not null,
      mult_name                   VARCHAR2(20) not null,
      mult_selected_multiple      VARCHAR2(1) not null,
      mult_anmw_multiple_code     VARCHAR2(3),
      mult_link_multiple_code     NUMBER(4),
      mult_jmw_multiple_type_code VARCHAR2(3),
      mult_auth_required          VARCHAR2(1),
      mult_prom_auth_required     VARCHAR2(1)
    )Destination tables being inserted into
    create table POR_MULTIPLE
      mult_multiple_num           NUMBER(4) not null,
      mult_name                   VARCHAR2(20) not null,
      mult_selected_multiple      VARCHAR2(1) not null,
      mult_anmw_multiple_code     VARCHAR2(3),
      mult_link_multiple_num      NUMBER(4),
      mult_jmw_multiple_type_code VARCHAR2(3),
      mult_auth_required          VARCHAR2(1),
      mult_prom_auth_required     VARCHAR2(1),
      mult_parent_num             NUMBER(4),
      mult_channel_num            NUMBER(4),
      mult_active_flag            VARCHAR2(1) not null
    create table MULTIPLE_GROUPS
      mgrp_num         NUMBER(4) not null,
      mgrp_description VARCHAR2(40) not null,
      mgrp_parent_num  NUMBER(4)
    )

  • BIG Trigger Problem!!!

    Hi friends,
    I need to write a before insert and update trigger,that Select and (insert respectively update) the same table.
    I tried some solutions
    like the solution of Tom -->askTom
    here is the Link http://asktom.oracle.com/~tkyte/Mutate/index.html
    but that don't work for me. The problem is that I have
    first to select something from Table A and then
    check this with the values which have to be inserted or updated in Table A. Only when the the new values(from one column) are not in Table A they can be inserted or updated.Otherwise the Trigger have to raise an error.
    Can somebody tell me a way how to implement such a trigger???Please with an example.
    thanxx
    Schoeib

    As far as I know there is no easy solution for this. There is a good reason why Oracle throws the mutating table exception in its BEFORE triggers. One possible way round it is to use a view with an INSTEAD OF trigger on it, and prevent people have direct access to the table..
    However, it does seem to be as though you are trying to get the database to resolve problems that really ought to solved at the front-end. If at all possible you should try to correct whatever application is entering data into your system.
    Cheers, APC

  • "creta user" in an "after insert" table trigger

    Dear members,
    I'm having trouble when I want to create an oracle user in a trigger after inserting in a table.
    It says that I don't have privileges to do so, but my user is DBA, and I can create a new user directly with no problem from this user.
    Do I need a special privilege for some actions through a trigger ?
    Is user creation possible at all in such a trigger ?
    Thanks for your help.

    My guess is that you have the create user privilege granted to you through a role, not directly. Stored procedures don't know about privileges you have through roles.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

Maybe you are looking for

  • HP Laserjet P1606dn -- Prints forever!

    If I enable duplex printing in printing preferences, and print, it will duplex my 1 sheet print request (2 pages, one on each side) and make unlimited copies until it runs out of paper or ink. If I enable duplex printing in the web interface. All pri

  • Making low resolution pictures look high

    Hello guys. I am new to this forumn and this is my first post. I am pretty good with Photoshop. I use Adobe Photoshop CS3. Here is what my question is. I have a rather low megapixel camera (4 mpx) and I am wondering how I can get my photos to appear

  • How to include "pages" and "documents" as different tabs in most popular item webpart from site collection ?

    Hello, I require to customize the most popular item web part that should show the "pages" and "documents" from entire site collection in different tabs in the same web part. can anyone suggest me the approach on the same ? Thanks and Regards, Dipti C

  • How do I make a String have a Listener?

    I want to be able to have a listener for a String's change event. Is there such a thing? How would I do it? i.e. If    String myString = ""; was changed to    myString = "New"; Could I have a listener that was registered to capture that event?

  • IDVD - IPhoto images never load - perpetual spinning gear

    When starting IDVD, the IPhoto library never loads (Aperture amd Photo Booth work fine and I can drag photos from IPhoto to IDVD). If I try to share an album, from IPhoto (share/send to IDVD), IDVD opens and the IPhoto says it is sending photos to ID