Before or After insert trigger on HR_API_TRANSACTION_VALUES

I am on the termination page of SSHR and after entering the details when clcked on 'Next' the validations built in before / after insert trigger of HR_API_TRANSACTION_VALUES does not retrieve the data and the error 'No data found' is displayed.
We do not have AME approval. When clicked on 'Next' it goes to the review page. When I do a select on the HR_API_TRANSACTION_VALUES the data do exists but the validation does not work.
We have Oracle HRMS 11i with database as 11g.
Please give a resolution at the earliest.

you can use
hr_transaction_api.set_varchar2_value
or
hr_transaction_api.set_number_value
based on what type of value that you want to update

Similar Messages

  • Using Database Change Notification instead of After Insert Trigger

    Hello guys! I have an after insert trigger that calls a procedure, which in turn is doing an update or insert on another table. Due to mutating table errors I declared the trigger and procedure as autonomously transactional. The problem is, that old values of my main tables are inserted into the subtable since the after insert/update trigger is fired before the commit.
    My question is how can I solve that and how could I use the change notification package to call my procedure? I now that this notification is only started after a DML/DDL action has been commited on a table.
    If you could show me how to carry out the following code with a Database Change Notification I'd be delighted. Furthermore I need to know if it suffices to set up this notification only once or for each client seperately?
    Many thanks for your help and expertise!
    Regards,
    Sebastian
    declare
    cnumber number (6);
    begin
    select count(*) into cnumber from (
    select case when (select date_datum
        from
          (select f.date_datum,
            row_number() over (order by f.objectid desc) rn
          from borki.fangzahlen f
          where lng_falle      = :new.lng_falle
          and int_fallennummer = :new.int_fallennummer
          and lng_schaedling   = :new.lng_schaedling
          and date_datum       > '31.03.2010'
        where rn=1) < (select date_datum
        from
          (select f.date_datum,
            row_number() over (order by f.objectid desc) rn
          from borki.fangzahlen f
          where lng_falle      = :new.lng_falle
          and int_fallennummer = :new.int_fallennummer
          and lng_schaedling   = :new.lng_schaedling
          and date_datum       > '31.03.2010'
        where rn=2) then 1 end as action from borki.fangzahlen
            where lng_falle      = :new.lng_falle
            and int_fallennummer = :new.int_fallennummer
            and lng_schaedling   = :new.lng_schaedling
            and date_datum       > '31.03.2010') where action = 1;
    if cnumber != 0 then
    delete from borki.tbl_test where lng_falle = :new.lng_falle
    and int_fallennummer = :new.int_fallennummer
    and lng_schaedling   = :new.lng_schaedling
    and date_datum       > '31.03.2010';
    commit;     
    pr_fangzahlen_tw_sync_sk(:new.lng_falle, :new.int_fallennummer, :new.lng_schaedling);

    It looks like you have an error in line 37 of your code. Once you fix that the problem should be resolved.

  • Can't able to use :NEW in after insert trigger

    When i am trying to assign value to an element of the NEW pseudo record, its giving error like :new pseudo record can't be used in this type of trigger.
    What exactly i've done is given below
    create or replace triger tri_name
    after insert
    on tab_name
    for each row
    begin
    if :new.x='123' then
    :new.y:=null;
    end if;
    end tri_name;
    Thanks & Regards
    --DKar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    from oracle documentation...
    Old and new values are available in both BEFORE and AFTER row triggers. A new column value can be assigned in a BEFORE row trigger, but not in an AFTER row trigger (because the triggering statement takes effect before an AFTER row trigger is fired). If a BEFORE row trigger changes the value of new.column, then an AFTER row trigger fired by the same statement sees the change assigned by the BEFORE row trigger.
    for more details read the documentation

  • Error in after insert trigger

    Hello all,
    I have a question about after insert trigger. Will be new row inserted and commited if after insert trigger returns error? Thank you.
    regards,
    Miha

    What is the error that u r facing?
    there could multiple reasons for that. Basically, u can't put commit in the trigger (unless it is an autonomous transaction). Share the pseudo-code of u r triiger, so that , problem can be identified.
    Cheers,
    Ram Kanala

  • Calling of Stored Procedure in After Insert Trigger

    Can I call a Stored Procedure in After Insert Trigger ?
    Please send a sample code (good example) of After Insert Trigger.
    Thanks.

    Kishore,
    I have two table WLCS_ORDER, WLCS_ORDER_LINE
    WLCS_ORDER - It holds order header information like
    ORDER_ID
    CUSTOMER_ID
    TRANSACTION_ID
    STATUS
    ORDER_DATE
    SHIPPING_METHOD
    SHIPPING_AMOUNT
    SHIPPING_CURRENCY
    PRICE_AMOUNT
    PRICE_CURRENCY
    SHIPPING_GEOCODE
    SHIPPING_STREET1
    SHIPPING_STREET2
    SHIPPING_CITY
    SHIPPING_STATE
    SHIPPING_COUNTRY
    SHIPPING_POBOX
    SHIPPING_COUNTY
    SHIPPING_POSTAL_CODE
    SHIPPING_POSTAL_CODE_TYPE
    SPECIAL_INSTRUCTIONS
    SPLITTING_PREFERENCE
    ORDER_SUBTOTAL
    WLCS_ORDER_LINE - It holds all order lines information like
    ORDER_LINE_ID
    QUANTITY
    PRODUCT_ID
    TAX_AMOUNT
    TAX_CURRENCY
    SHIPPING_AMOUNT
    SHIPPING_CURRENCY
    UNIT_PRICE_AMOUNT
    UNIT_PRICE_CURRENCY
    MSRP_AMOUNT
    MSRP_CURRENCY
    DESCRIPTION
    ORDER_ID
    TOTAL_LINE_AMOUNT
    Relation between WLCS_ORDER, WLCS_ORDER_LINE is one to many.
    For each WLCS_ORDER row, one or more order lines will insert into WLCS_ORDER_LINE table.
    For each new row in WLCS_ORDER table, I have to update the following columns in both the tables with my maths.
    WLCS_ORDER
    shipping_amount
    price_amount
    order_subtotal
    WLCS_ORDER_LINE
    shipping_amount
    I thought I can do this in after insert trigger, But if it is not possible, Please give the best way to fulfill this requirement.
    I appreciate your help.
    Have a great day.
    Srinivas

  • After Insert Trigger with DML on the subject table?

    I am trying to set up e-mail notifications, so I created a procedure, which accepts the argument of an id. In the procedure, it queries the table and sends out mail based on the result set. (in the trigger, I pass in the value of :NEW.id). The procedure then queries the table for that row id.
    First, for the after update I was getting the error:
    ORA-04091: table is mutating, trigger/function may not see it ORA-06512
    So, I was advised to do in the declare block: pragma autonomous_transaction; I did that, and that solved the problem there. SO I did the same in the after insert trigger, but then I get the error:
    ORA-00060: deadlock detected while waiting for resource ORA-06512
    I asked our DBA and he said you are not able to query the table of which the trigger is a subject of. I thought it would be possible since its After insert or update?
    Can anyone offer any suggestions ? :)
    Thanks,
    Trent

    Any reason why it would work in an after update trigger then?
    So, I was advised to do in the declare block: pragma autonomous_transaction; I did that, and that solved the problem therePRAGMA AUTONOMOUS_TRANSACTION "bends" the restriction against SQL against base table.
    It is the equivalent to tap dancing across a mine field.
    You might get the desired results most of the time or you might get a tasty surprise when you least expect it.
    What happens to your application in the future, if/when the UPDATE has a ROLLBACK issued & PRAGMA AUTONOMOUS_TRANSACTION has successfully completed?
    Inquiring minds would like to know the answer.

  • After insert trigger with :NEW.ROWID

    Hi All,
    I am using a After insert trigger to generate history record as following:
    CREATE TABLE TB_TEST (classID number(3), classNm varchar2(12));
    CREATE TABLE TB_HIST_TEST (hist_dttm timestamp(6), classID number(3), classNm varchar2(12));
    CREATE or REPLACE TRIGGER air_test AFTER INSERT ON tb_test FOR EACH ROW
    BEGIN PK_SRVC.CRT_NewRec('TB_TEST', 'TB_HIST_TEST', :new.ROWID); END:
    In PK_SRVC package, I use the following statment to create new record in TB_HIST_TABLE:
         Insert into tb_hist_test (hist_dttm, classID, classNm)
         values (select systimestamp, classID, classNm from tb_test where rowid = ROWID )
    The trigger DOES fire when a new row is inserted into TB_TEST. However there is no record inserted into TB_HIST_TEST. Any suggestion?
    Thanks,

    The PK_SRVC.CRT_NewRec is a generic service package that can be shared by many tables. It uses dynamic SQL to get all the collumns for different tables based on USER_TAB_COLUMNS.  The following is the code of this package:
    PROCEDURE CRT_NewRec ( p_TableName IN VARCHAR2, p_AudTableName IN VARCHAR2, p_RowID)
    IS
           TYPE TabCol_RecTyp IS RECORD (COLUMN_NAME VARCHAR2(30), COLUMN_ID NUMBER);
           TYPE TabCol_CurTyp IS REF CURSOR;
            c_TabCol TabCol_CurTyp;
            rc_TabCol TabCol_RecTyp;
            v_Sql_TabCol VARCHAR2(1000);
            v_ColNames VARCHAR2(1000);
            v_Sql VARCHAR2(1000);
            PRAGMA AUTONOMOUSE_TRANSCATION;
    BEGIN
            v_SQL_TabCol := ' SELECT column_name, column_id FROM USER_TAB_COLUMNS'
                                      ||  ' WHERE table_name = ' || CHR(39) || p_TableName || CHR(39)
                                      || '  ORDER BY column_id';
            v_ColNames := NULL;
            OPEN c_TabCol FOR v_Sql_TabCol;
            Loop
                   FETCH c_TabCol INTO rc_TabCol; Exit WHEN c_TabCol%NOTFOUND:
                   v_ColNames := v_ColNames || ',' || rc_TabCol.COLUMN_NAME;
            End Loop;
            CLOSE c_TabCol;
            v_Sql := 'INSERT INTO ' || p_AudTableName || '(HIST_DTTM, ' || v_ColNames || ' )'  
                      || ' SELECT systimestamp, ' || v_ColNames || ' FROM ' || p_TableName
                      || ' WHEN ROWID = chartorowid(' || CHR(39) || p_RowId || CHR(39) || ')';
             EXECUTE IMMEDIATE v_Sql;
             COMMIT;
    END;    
    (charmingholidays-yyz)

  • After insert trigger

    Dears,
    In after insert trigger implementation if the base table failed due to some errors.
    Is it possible to still have records inserted in the log table inside the trigger
    Thanks
    Janani.C

    What you want is to write log records to a table, regardless of whether the transaction they're logging fails. This would make sense for inevstigating errors,e tc. This is the only time when it is acceptable to use autonomous transactions.
    Encapsulate your logguing code in a separate procedure which has the {font:courier new}PRAGMA autonomous_transaction{font} in its declaration, and include a commit. Such a procedure works in its own separate tranasction - a separate session in fact - and write the log record without affecting the broader transaction. [url http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1515]Find out more.
    Cheers, APC
    P.S. I agree with Hoek that you should investigate teh LOG ERRORS INTO functionality, as it can be very useful, especially with bulk processes. However, it can only store information directly relating to the rejected records, which might not be sufficient for your purposes.

  • After Insert Trigger - IF-THEN-ELSE

    Is it possible to put an if-then-else statement in an after insert trigger with an update to a second table?
    CREATE OR REPLACE trigger bev_trg
    after insert
    on bev
    for each row
    DECLARE
    MEINS VARCHAR2(3);
    SPART VARCHAR2(2);
    FKIMG NUMBER(22);
    SHKZG CHAR(1);
    BEGIN
    insert into bev2
    (vbeln,
    posnr)
    values
    (:new.vbeln,
    :new.posnr
    IF FKIMG = '10' and MEINS = 'EA'
    THEN
         update bev2 set bwsie = (fkimg * '12.17') ;
    ELSIF
    FKIMG = '12' and MEINS = 'EA'
    THEN
         update bev2 set bwsie = (fkimg * '19.02');
    ELSIF
    SHKZG = 'X'
    THEN
         update bev2 set bwsie = (fkimg * '-1');
    ELSE
         update bev2 set bwsie = '0' ;
    END IF;
    update bev2 set bwfkimg = (fkimg * '-1') where SHKZG = 'X';
    end;
    This does not do the updates.
    Thanks
    Bev

    My original problem is this: I need to create a table
    derived from data in another table
    and change it to be the conditional data in the update statements.
    create table bev(
    VBELN VARCHAR2(10),
    POSNR VARCHAR2(6),
    MEINS VARCHAR2(3),
    SPART VARCHAR2(2),
    FKIMG NUMBER(22),
    SHKZG CHAR(1),
    BWSIE NUMBER(9,2),
    BWFKIMG NUMBER(22)
    update bev set bwsie = (fkimg * '12.17') where SPART = '10' and meins = 'EA' ;
    update bev set bwsie = (fkimg * '19.02') where SPART = '12' and meins = 'EA';
    update bev set bwsie = (fkimg * '27.39') where SPART = '15' and meins = 'EA';
    update bev set bwsie = (fkimg * '48.69') where SPART = '20' and meins = 'EA';
    update bev set bwsie = (fkimg * '109.56') where SPART = '30' and meins = 'EA';
    update bev set bwsie = '0' where meins = 'EA' and SPART not in('10','12','15','20','30');
    update bev set bwsie = (fkimg * '-1') where SHKZG = 'X';
    update bev set bwfkimg = (fkimg * '-1') where SHKZG = 'X';
    This did not produce the required results so I thought I would try
    creating a second table
    and using a trigger with if-then-else to update it.
    Can't use the trigger on the
    original table because it mutates.
    create table bev2(
    VBELN VARCHAR2(10),
    POSNR VARCHAR2(6),
    BWSIE NUMBER(9,2),
    BWFKIMG NUMBER(22)
    insert into bev select vbeln, posnr, meins, spart, fkimg , shkzg, '', ''
    from [email protected]
    where vbeln = '0090043834' and posnr = '000011'
    insert into bev select vbeln, posnr, meins, spart, fkimg , shkzg, '', ''
    from [email protected]
    where vbeln = '0090043833' and posnr = '000011'
    CREATE OR REPLACE trigger bev_trg
    after insert
    on bev
    for each row
    DECLARE
    MEINS VARCHAR2(3);
    SPART VARCHAR2(2);
    FKIMG NUMBER(22);
    BEGIN
    insert into bev2
    (vbeln,
    posnr,
    fkimg
    values
    (:new.vbeln,
    :new.posnr,
    :new.fkimg
    IF :new.FKIMG = '10' and :new.MEINS = 'EA'
    THEN
    update bev2 set bwsie = (:new.fkimg * '12.17') ;
    ELSIF
    :new.FKIMG = '12' and :new.MEINS = 'EA'
    THEN
    update bev2 set bwsie = (:new.fkimg * '19.02');
    ELSIF
    :new.FKIMG = '15' and :new.MEINS = 'EA'
    THEN
    update bev2 set bwsie = (:new.fkimg * '27.39');
    ELSIF
    :new.FKIMG = '20' and :new.MEINS = 'EA'
    THEN
    update bev2 set bwsie = (:new.fkimg * '48.69');
    ELSIF
    :new.FKIMG = '30' and :new.MEINS = 'EA'
    THEN
    update bev2 set bwsie = (:new.fkimg * '109.56');
    ELSIF
    SHKZG = 'X'
    THEN
    update bev2 set bwsie = (:new.fkimg * '-1');
    ELSE
    update bev2 set bwsie = '0' ;
    END IF;
    update bev2 set bwfkimg = (:new.fkimg * '-1') where SHKZG = 'X';
    end;

  • After insert trigger issue

    Hi All,
    Can I have an after insert trigger on a table wherein the execution is also on the same table?
    It's like 10 columns in the table A.
    During a new row insertion, except one specific column(say 'J'), remaining all getting data.
    Now 'after insert', need to update the data of the column J based on one inserted value for column say ID.
    Code goes like below:
    CREATE OR REPLACE TRIGGER UPDATE_J
    AFTER INSERT ON A REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    begin
    if :new.ID = 'N%' then
         :new.J:= 'N';
    else
         :new.J:= 'M';
    end if;
    end;
    Below is the error when I tried to execute that.
    ORA-04091: table string.string is mutating, trigger/function may not see it
    Cause: A trigger (or a user defined plsql function that is referenced in this statement) attempted to look at (or modify) a table that was in the middle of being modified by the statement which fired it.
    Action: Rewrite the trigger (or function) so it does not read that table.
    Any idea to resolve?
    Regards,
    Seetharaman.

    Hi,
    The docs say
    Restrictions on AFTER
          An AFTER row trigger or AFTER row section of a compound trigger can only read but not write into the :OLD or :NEW fields. When faced with problems like this, it is always a good thing to consult the documentation.
    Regards
    Peter

  • Update by after insert trigger

    I need to update each new inserted row of data by checking if there were same values in the table. So I tried the After Insert Trigger with the code below :
    CREATE OR REPLACE TRIGGER approve_checker
    after insert on TBL_BILL
    for each row
    declare
    counter integer;
    begin
    SELECT COUNT() INTO counter FROM TBL_BILL WHERE issue_date=:NEW.issue_date AND wagon_no=:NEW.wagon_no ;*
    IF( counter > 1)
    THEN
    UPDATE TBL_BILL SET approved = 2 WHERE id = :NEW.id;
    END IF;
    end approve_checker;
    But errors accured :
    ORA-04091: table RAIL.BILL is mutating, trigger/function may not see it
    ORA-06512: at "RAIL.APPROVE_CHECKER", line 4
    ORA-04088: error during execution of trigger 'RAIL.APPROVE_CHECKER'
    Any help appreciated.

    You cannot SELECT from the table on which the row-level trigger is defined, nor can you UPDATE a table on which the row-level trigger is defined. If you are inserting multiple rows in a single INSERT statement, Oracle can't be sure what rows to update and/or select.
    Is there a reason that you wouldn't just create a unique constraint to enforce this condition?
    Justin

  • Difference between Before INSERT and After INSERT trigger?

    What is difference between Before INSERT and After INSERT triggers? Can anyone give me a simple example from SCOTT schema for both of these triggers.

    The documentation gives a good explanation have you looked at....
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1175

  • After insert trigger error

    Hi,
    i have created an Trigger After Insert According to me, It's correct But it show me Error Can Not Insert Null in to code.
    CREATE OR REPLACE TRIGGER  "AFT_INS_CRM_CUSTOMER_CONTACTS"
      AFTER INSERT ON FH_TAPROD.CRM_SALES_CUSTOMER_CONTACTS
    FOR EACH ROW
    DECLARE
    custo_id NUMBER;
    var_code varchar2(8);
    cont_code varchar2(5);
    BEGIN
    SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =:NEW.ID;
      select CODE into var_code from VENDOR_CUSTOMER_MAS where CRM_CUST_ID=custo_id ;
      SELECT LPAD ( NVL(MAX(CONTACT_CODE), 0)+ 1, 5, '0') into cont_code FROM vendor_customer_contact
      insert into VENDOR_CUSTOMER_CONTACT(SBU_CODE ,CODE,CONTACT_CODE, CONTACT_NAME ,PHONE_NO1 ,MOBILE_NO ,EMAIL, ADDRESS1,CUST_ID,UPLOAD_CRM)
       values('0002',var_code,cont_code,:NEW.CONTACT_NAME,:NEW.CONTACT_PHONE,:NEW.CONTACT_CELL,:NEW.CONTACT_EMAIL,:NEW.CONTACT_ADDRESS,custo_id,'CRM');
    END;
    CREATE TABLE  "CRM_SALES_CUSTOMER_CONTACTS"
       (     "ID" NUMBER,
         "CUSTOMER_ID" NUMBER,
         "CONTACT_NAME" VARCHAR2(255),
         "CONTACT_EMAIL" VARCHAR2(255),
         "CONTACT_PHONE" VARCHAR2(255),
         "CONTACT_CELL" VARCHAR2(255),
         "CONTACT_ADDRESS" VARCHAR2(4000),
          PRIMARY KEY ("ID") ENABLE
    INSERT INTO CRM_SALES_CUSTOMER_CONTACTS VALUES (204414862717175278810736770347803084847, 204232590877603599356756434170666837075, 'SANJAY',    '[email protected]', 1246456, 57152357,'Near Post Office');
    CREATE OR REPLACE TRIGGER  "BIU_CRM_SALES_CUST_CONTACTS"
    BEFORE INSERT OR UPDATE ON CRM_SALES_CUSTOMER_CONTACTS
        FOR EACH ROW
    begin
        if inserting and :new.id is null then
            select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') into :new.id from dual;
        end if;
        if inserting then
            :new.created_by := nvl(v('APP_USER'),USER);
            :new.created_on := sysdate;
        end if;
        if updating then
            :new.updated_by := nvl(v('APP_USER'),USER);
            :new.updated_on := sysdate;
        end if;
    end;My After Insert TAble
    CREATE TABLE  "VENDOR_CUSTOMER_CONTACT"
       (     "SBU_CODE" VARCHAR2(4) NOT NULL ENABLE,
         "CODE" VARCHAR2(8) NOT NULL ENABLE,
         "CONTACT_CODE" VARCHAR2(5) NOT NULL ENABLE,
         "CONTACT_NAME" VARCHAR2(1000) NOT NULL ENABLE,
         "PHONE_NO1" VARCHAR2(100),
         "MOBILE_NO" VARCHAR2(25),
         "EMAIL" VARCHAR2(1000),
         "ADDRESS1" VARCHAR2(4000),
         "CUST_ID" NUMBER,
         "UPLOAD_CRM" VARCHAR2(10),
          CONSTRAINT "VCV_PK" PRIMARY KEY ("SBU_CODE", "CODE", "CONTACT_CODE") ENABLE
    ORA-01400: cannot insert NULL into ("FH_TAPROD"."VENDOR_CUSTOMER_CONTACT"."CODE") ORA-06512: at "FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS", line 30 ORA-04088: error during execution of trigger 'FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS'How to resolve it.
    Thanks
    Edited by: 805629 on Jan 14, 2011 1:26 AM

    This is your trigger
    CREATE OR REPLACE TRIGGER  "AFT_INS_CRM_CUSTOMER_CONTACTS"
      AFTER INSERT ON FH_TAPROD.CRM_SALES_CUSTOMER_CONTACTS
    FOR EACH ROW
    DECLARE
    custo_id NUMBER;
    var_code varchar2(8);
    cont_code varchar2(5);
    BEGIN
    SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =:NEW.ID;
      select CODE into var_code from VENDOR_CUSTOMER_MAS where CRM_CUST_ID=custo_id ;
      SELECT LPAD ( NVL(MAX(CONTACT_CODE), 0)+ 1, 5, '0') into cont_code FROM vendor_customer_contact;
      insert into VENDOR_CUSTOMER_CONTACT(SBU_CODE ,CODE,CONTACT_CODE, CONTACT_NAME ,PHONE_NO1 ,MOBILE_NO ,EMAIL, ADDRESS1,CUST_ID,UPLOAD_CRM) values('0002',var_code,cont_code,:NEW.CONTACT_NAME,:NEW.CONTACT_PHONE,:NEW.CONTACT_CELL,:NEW.CONTACT_EMAIL,:NEW.CONTACT_ADDRESS,custo_id,'CRM');
    END;This is the insert who fire it
    INSERT INTO CRM_SALES_CUSTOMER_CONTACTS VALUES (204414862717175278810736770347803084847, 204232590877603599356756434170666837075, 'SANJAY',    '[email protected]', 1246456, 57152357,'Near Post Office');Then the trigger execute
    SELECT CUSTOMER_ID FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =204232590877603599356756434170666837075;
    select CODE from VENDOR_CUSTOMER_MAS where CRM_CUST_ID=<result of previous query>;
    SELECT LPAD ( NVL(MAX(CONTACT_CODE), 0)+ 1, 5, '0') FROM vendor_customer_contact;
    Insert ...And fail.
    Execute the select in your sqlplus one by one and post result.

  • 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.

  • After Insert Trigger Not Working

    Hi All,
    I am not a guru in writing triggers.
    I am inserting new records in a Table FA_BOOKS by application and this inserts records in FA_ADDITIONS_B. This is a vanilla process.
    i have written a trigger on FA_ADDITIONS_B, and i want to update the cost from the fa_books to fa_additions_b column attribute21
    The trigger i have written is After insert on FA_ADDITIONS_B and i try to select cost from the fa_books for the :new.asset_id.
    SELECT COST
    INTO v_cost
    FROM FA_BOOKS
    WHERE ASSET_ID = :NEW.ASSET_ID;
    this is always returning no_data_found exception and i do not understand how to update the attribute21 in FA_ADDITIONS_B
    Here is a sample of my trigger.
    CREATE OR REPLACE TRIGGER update_attribute21_new_asset_1
    after INSERT ON fa_ADDITIONS_B
    FOR EACH ROW
    DECLARE
    V_COST NUMBER;
    BEGIN
    SELECT COST
    INTO v_cost
    FROM FA_BOOKS
    WHERE ASSET_ID = :NEW.ASSET_ID;
    update fa_ADDITIONS_B
    set attribute21 = v_cost
    where ASSET_ID = :NEW.ASSET_ID;
    END;
    Any help on this will be appreciated.
    TX in advance.
    Regards,

    I still haven't understood the reason why you can't transfer the COST information from FA_BOOKS to FA_ADDITIONS_B in the initial trigger on FA_BOOKS that populates FA_ADDITIONS_B. Or how is the population of FA_ADDITIONS_B accomplished? Is it part of the application code?
    Regarding the NO_DATA_FOUND issue:
    Is it ensured that populating the FA_ADDITIONS_B table is done in the same transaction as the FA_BOOKS inserts or that the FA_BOOKS transaction is committed?
    Why do you need that additional trigger?
    My assumption is that you're in a trigger "chain" - if I get your approach correctly - you're basically attempting to query FA_BOOKS in a trigger on FA_ADDITIONS_B that in turn has been triggered by a trigger on FA_BOOKS which gets us back to the "mutating" trigger issue. You can't read a table that is currently in the process of being modified.
    Or even worse: The (potential) trigger on FA_BOOKS that populates FA_ADDITIONS_B uses "autonomous transaction" and therefore the trigger on FA_ADDITIONS_B can't see the changes of the original transaction.
    As already mentioned: Be very careful with "autonomous transactions" in general. There are only a few cases where these are actually useful (e.g. logging purposes), but Tom Kyte has written numerous articles why triggers and in particular autonomous transactions are mostly evil.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

Maybe you are looking for

  • SQL report link to another report

    Hello, I am using Apex 4 and trying to link an sql report with another report. If I were able to use an interactive report I could easily link that to another page, but that would require me to have a primary key. The problem is that I need to link a

  • Nokia N95 8GB takes ages refreshing even for one t...

    Hi All. I have had this REALLY frustrating problem... Every time i add a track to my phone, then i refresh it takes AGES to update the library. Does anyone know how to fix this? Nokia N97 Mini V: 10.0.020 : 14/10/09 RM-555 Old: N95 8GB : V 20.0.016 :

  • Ipod connection issues with itunes

    i know, i am the one-thousandth person to write in about a connection issue, but i just bought a 8gb nano. my pc is recognizing the ipod, but itunes does not automatically start. instead, if i manually try to start up itunes, it either doesn't start

  • Unable to view photos in iPhoto unless same day import

    I imported and edited a bunch of photos in iPhoto yesterday, but when I went to use them today, all I see are blank thumbnails. When I click on these, there's no picture. I can only see the photos I imported today. Where did all my other photos go? A

  • Is it possible to sort / group movies by video quality?

    I'd like to sort or group my movies by video quality.  I am not sure if it's possible in iTunes -- if it is, I certainly can't figure it out. I can certainly see the info when I click "Get Info" on individual films, but I don't see a way to sort or c