INSTEAD OF trigger on view to update a table. error in 4.2apex tabular rpt

I have created a view (LANDINGS_VIEW') that I am hoping to use to add/modify data over several tables. I am using INSTEAD OF trigger to update/insert into the underlying tables. I am receiving the error:
•ORA-01858: a non-numeric character was found where a numeric was expected ORA-06512: at "SAFIS.LANDINGS_V_IO_UPD_TRG", line 4 ORA-04088: error during execution of trigger 'SAFIS.LANDINGS_V_IO_UPD_TRG' (Row 1)I am only setting PRICE = 300.
any thoughts? Am I setting this up propertly? thanks for your help!!
Karen
The LANDING_VIEW is set up as follows:
-- Start of DDL Script for View SAFIS.LANDINGS_VIEW
-- Generated 03-May-2013 10:25:38 from [email protected]
CREATE OR REPLACE VIEW landings_view (
   landing_seq,
   dealer_rpt_id,
   unit_measure,
   reported_quantity,
   landed_pounds,
   dollars,
   disposition_code,
   grade_code,
   species_itis,
   market_code,
   price,
   area_fished,
   sub_area_fished,
   lease_num,
   gear_code,
   de,
   ue,
   dc,
   uc,
   local_area_code,
   fins_attached,
   explanation,
   late_report,
   modified_data,
   nature_of_sale,
   hms_area_code,
   sale_price,
   deleted )
AS
select l.LANDING_SEQ,
       l.DEALER_RPT_ID,
       l.UNIT_MEASURE,
       l.REPORTED_QUANTITY,
       l.LANDED_POUNDS,
       l.DOLLARS,
       l.DISPOSITION_CODE,
       l.GRADE_CODE,
       l.SPECIES_ITIS,
       l.MARKET_CODE,
       l.PRICE,
       l.AREA_FISHED,
       l.SUB_AREA_FISHED,
       l.LEASE_NUM,
       l.GEAR_CODE,
       l.DE,
       l.UE,
       l.DC,
       l.UC,
       l.LOCAL_AREA_CODE,
       a.fins_attached,
       a.explanation,
       a.late_report,
       a.modified_data,
       a.nature_of_sale,
       a.hms_area_code,
       a.sale_price,
       a.deleted
  from landings l,
       landings_hms a
  where  l.dealer_rpt_id = v('P110_DEALER_RPT_ID') and
        l.dealer_rpt_id = a.dealer_rpt_id(+) and
        l.landing_seq = a.landing_seq(+)
-- Triggers for LANDINGS_VIEW
CREATE OR REPLACE TRIGGER landings_v_io_upd_trg
INSTEAD OF
  UPDATE
ON landings_view
REFERENCING NEW AS NEW OLD AS OLD
DECLARE
   v_first_day   date;
   BEGIN
update landings set landing_seq = :old.landing_seq,
                          dealer_rpt_id = :old.dealer_rpt_id,
                          unit_measure = :new.unit_measure,
                          reported_quantity = :new.reported_quantity,  
                        --  landed_pounds = :new.landed_pounds,
                          dollars = :new.dollars,
                          disposition_code= :new.disposition_code, 
                          grade_code = :new.grade_code,
                          species_itis =  :new.species_itis,
                           market_code = :new.market_code,
                          price =  :new.price,
                          area_fished = :new.area_fished,
                          sub_area_fished = :new.sub_area_fished,
                       --   lease_num = :new.lease_num,
                          gear_code = :new.gear_code,
                          de = :new.de,
                          ue = :new.ue,
                          dc = :new.ue,
                          uc = :new.uc,
                          local_area_code =  :new.local_area_code ;     
    /*  update landings_hms  set dealer_rpt_id = :old.dealer_rpt_id,
                             landing_seq = :old.landing_seq,
                             fins_attached = :new.fins_attached,
                             explanation = :new.explanation,
                             late_report = :new.late_report,
                             modified_data = :new.modified_data,
                             nature_of_sale = :new.nature_of_sale,
                             hms_area_code = :new.hms_area_code,
                             sale_price = :new.sale_price,
                             de = sysdate,
                             ue = :new.ue,
                             dc = :new.dc,
                             uc = :new.uc ;                         
end;
-- End of DDL Script for Trigger SAFIS.LANDINGS_KEH_V_IO_TRG
CREATE OR REPLACE TRIGGER landings_v_io_trg
INSTEAD OF
  INSERT
ON landings_view
REFERENCING NEW AS NEW OLD AS OLD
DECLARE
   v_first_day   date;
   BEGIN
insert into landings_keh (landing_seq,
                          dealer_rpt_id,
                          unit_measure,
                          reported_quantity,
                          landed_pounds,
                          dollars,
                          disposition_code,
                          grade_code,
                          species_itis,
                          market_code,
                          price,
                          area_fished,
                          sub_area_fished,
                          lease_num,
                          gear_code,
                          de,
                          ue,
                          dc,
                          uc,
                          local_area_code)      
   values ( landings_seq.NEXTVAL,
            :new.dealer_rpt_id,
            :new.unit_measure,
            :new.reported_quantity,
            :new.landed_pounds,
            :new.dollars,
            :new.disposition_code,
            :new.grade_code,
            :new.species_itis,
            :new.market_code,
            :new.price,
            :new.area_fished,
            :new.sub_area_fished,
            :new.lease_num,
            :new.gear_code,
            sysdate,
            :new.ue,
            :new.dc,
            :new.uc,
            :new.local_area_code)  ;
   insert into landings_hms (dealer_rpt_id,
                             landing_seq,
                             fins_attached,
                             explanation,
                             late_report,
                             modified_data,
                             nature_of_sale,
                             hms_area_code,
                             sale_price,
                             de,
                             ue,
                             dc,
                             uc,
                             deleted)
       values (:new.dealer_rpt_id,
               landings_seq.CURRVAL,
               :new.fins_attached,
               :new.explanation,
               :new.late_report,
               :new.modified_data,
               :new.nature_of_sale,
               :new.hms_area_code,
               :new.sale_price,
               sysdate,
               :new.ue,
               :new.dc,
               :new.uc,
               :new.deleted);
end;
-- End of DDL Script for Trigger SAFIS.LANDINGS_KEH_V_IO_TRG
-- End of DDL Script for View SAFIS.LANDINGS_VIEWbtw, I have succefully run the following update in sqlplus.
update landings set landing_seq = 8604583,
dealer_rpt_id = 2660038,
unit_measure = 'LB',
reported_quantity = 3,
-- landed_pounds = :new.landed_pounds,
dollars = 900,
disposition_code= '001',
grade_code = '10',
species_itis = '160200',
market_code = 'UN',
price = 30,
area_fished = null,
sub_area_fished =null,
-- lease_num = :new.lease_num,
gear_code = '050',
de = sysdate,
ue = 'keh',
dc = null,
uc = 'keh',
local_area_code = null
where landing_seq = 8604583; I am using apex 4.2
Edited by: KarenH on May 3, 2013 10:29 AM
Edited by: KarenH on May 3, 2013 10:31 AM
Edited by: KarenH on May 3, 2013 11:04 AM
Edited by: KarenH on May 3, 2013 4:09 PM

could it be so simple?
when I created the tabular form on my view, LANDINGS_VIEW, the APPLYmru was automatically generated, referencing the view name LANDINGS_VIEW. I modified that to indicate the table name (LANDINGS). I am not certain why that would work, but it seems to so far.
this post was helpful: Re: instead of trigger on view
I am now testing to make certain both the underlying tables can be updated, LANDINGS and LANDINGS_HMS

Similar Messages

  • Instead-of Trigger of View on a Remote Table Fails!!!

    Hi all,
    I'm trying to create an INSTEAD OF (UPDATE or INSERT) trigger on a view V1 in DATABASE DB1 (Linux 7.3 or 7.2, ORACLE 9.2.0.1.0 - Production).The view V1 is created on a remote table through a DBLINK.But I always get such error when I update the view V1 using statements such as "update v1 set oid=oid+1000" :
    ORA-03113 end-of-file on communication channel
    But I can execute those statements successfully in Oracle of version 9.0.1.0.0 .
    What I want to say is that if some special configs is needed to support instead-of trigger of a view on a remote table ?

    Hi all,
    I'm trying to create an INSTEAD OF (UPDATE or INSERT) trigger on a view V1 in DATABASE DB1 (Linux 7.3 or 7.2, ORACLE 9.2.0.1.0 - Production).The view V1 is created on a remote table through a DBLINK.But I always get such error when I update the view V1 using statements such as "update v1 set oid=oid+1000" :
    ORA-03113 end-of-file on communication channel
    But I can execute those statements successfully in Oracle of version 9.0.1.0.0 .
    What I want to say is that if some special configs is needed to support instead-of trigger of a view on a remote table ?

  • Instead of trigger on view

    I created a view to use in a tabular form and only need to update one column from one table of that view. How do I write the instead of trigger to accomplish this? The field that I am trying to update is a select list-yes/no column in the tabular form. Upon submit with the wizard MRU and the instead of trigger I wrote the update doesn't take effect.
    Without the trigger I get this error:
    ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved tableHere's the view:
    CREATE OR REPLACE FORCE VIEW  "GET_USERNAME_VW" ("DOC_INFO_ID", "DOC_TITLE", "DOC_LINK", "ECRNO", "OWNER", "ISO_NUMBER", "STATUS_ID", "FILE_TYPE", "APPROVAL_REQ", "APPROVED", "JOB_DESC", "USER_NAME") AS
      select     "DOC_INFO"."DOC_INFO_ID" as "DOC_INFO_ID",
         "DOC_INFO"."DOC_TITLE" as "DOC_TITLE",
         "DOC_INFO"."DOC_LINK" as "DOC_LINK",
         "DOC_INFO"."ECRNO" as "ECRNO",
         "DOC_INFO"."OWNER" as "OWNER",
         "DOC_INFO"."ISO_NUMBER" as "ISO_NUMBER",
         "DOC_INFO"."STATUS_ID" as "STATUS_ID",
         "DOC_INFO"."FILE_TYPE" as "FILE_TYPE",
         "DOC_INFO"."APPROVAL_REQ" as "APPROVAL_REQ",
         "DOC_INFO"."APPROVED" as "APPROVED",
         "SH_JOB_DESCRIPTION"."JOB_DESC" as "JOB_DESC",
         "SH_EMPLOYEES"."USER_NAME" as "USER_NAME"
    from     "SH_EMPLOYEES" "SH_EMPLOYEES",
         "SH_JOB_DESCRIPTION" "SH_JOB_DESCRIPTION",
         "DOC_INFO" "DOC_INFO"
    where   "DOC_INFO"."OWNER"="SH_JOB_DESCRIPTION"."JOB_DESC"
    and     "SH_JOB_DESCRIPTION"."JOB_DESC_ID"="SH_EMPLOYEES"."JOB_DESC_ID"
    and "DOC_INFO"."STATUS_ID" IN (1,2)
    /Here's the trigger I created
    CREATE TRIGGER GET_APPROVAL
    INSTEAD OF UPDATE ON GET_USERNAME_VW
    REFERENCING NEW AS n                
    FOR EACH ROW
    BEGIN
    update doc_info set approval_req = :n.approval_req
    END;As always, TIA!
    Alexandra
    Edited by: userRRRYB on Jul 11, 2011 4:16 PM - ADDED VIEW

    Alexandra,
    You're going to get that error when creating a tabular form off of a complex view because of the validations APEX creates for you, not because of your trigger. Delete those validations and try again.
    Of course, you're going to want to add the where clause to your trigger, or you'll find that you're updating many more rows than you want...
    -David

  • Instead of trigger on view with CLOB data

    I have writed Instead of trigger for view "article(id,text)" with CLOB
    field "text".
    create or replace trigger v_article_insert
    instead of insert on v_article
    for each row
    declare
    begin
    insert into article(id,text) values(id,:new.text);
    end v_article_insert;
    When I try to do DML (insert, update), forexample:
    insert into v_article(text) values('bla-bla')
    I get:
    ORA-25008 no implicit conversion to LOB datatype in instead-of trigger.
    ( Cause: When inserting or updating a view using instead-of trigger, the
    new value for a LOB view column is of a different datatype.
    Action: Specified a LOB value as the new value for the LOB view
    column.)
    insert into v_article(text) values(empty_clob()) - It works...
    What does it mean and what is right syntax for DML for CLOB fields in
    instead of triggers?

    When inserting CLOBs you create the row with an Empty_Clob() to initialize the CLOB field. Then you can update the empty CLOB with your CLOB value.
    The error message is telling you that Oracle will not convert your CLOB to the initialization value needed.

  • Instead of trigger on view error

    I've created a view, a form on that view and an INSTEAD OF update trigger on that view. When I press the update button in the form I get
    Error: An unexpected error occurred: ORA-22816: unsupported feature with RETURNING clause (WWV-16016)
    The error changes if I remove the trigger, but I need the trigger because the view is not updateable. I've recreated the problem with a simple view on the emp table.
    Here's the emp view and trigger.
    create or replace view vw_emp
    as select *
    from emp;
    create or replace trigger vw_emp_burow
    instead of update on vw_emp
    referencing new as new old as old
    for each row
    begin
    null;
    end;In the emp case, the update proceeds fine once I drop the trigger.
    Is this a bug or have I done something wrong? Has anyone else tried this?
    (Portal 3.0.6.6.5 on 8.1.7 on Solaris)
    Responses appreciated.

    I was on the beta program, and ran into this problem with the beta version, and the EA version. Oracle told me that because of the underlying architecture of Oracle Portal, this was not easy to fix, so it would not be fixed in any 3.0 release.
    I am hoping they fix it in the 3.1 release, though that will not be out until something like next August.
    This is really an annoying bug, because using INSTEAD OF triggers on views would be a great way to make views that work well with Oracle Portal, while keeping the database normalized!
    Ken Atkins
    Computer Resource Team (www.crtinc.com)
    Check out my Oracle Tip site at:
    http://www.arrowsent.com/oratip
    null

  • Need help with INSTEAD OF trigger on view

    Hi,
    I am trying to use INSTEAD OF on a view because I will be updating the calling table in my trigger, which will cause mutation. 
    I need to update attribute7 of another record based on the new attribute7 of the current record (record being updated in the form).  Below is my script.  My problem is it does not perform the update. 
    create or replace view xxont_oe_order_lines_vw as select * from oe_order_lines_all;
    CREATE OR REPLACE TRIGGER APPS.xxont_sync_ard
    instead of insert or update on xxont_oe_order_lines_vw
    referencing
    new as new
    old as old
    for each row
    begin
       update oe_order_lines_all
           set attribute7 = :new.attribute7
       where attribute18 = to_char(:new.header_id)
          and attribute17 = to_char(:new.line_id)
          and flow_status_code <> 'CANCELLED' ;      
      /*exception
      when others then
         null ;
      end ;*/        
    end ;

    Always make your code developer friendly. Do extensive code instrumentation. At lease you can do this.
    create or replace trigger apps.xxont_sync_ard
    instead of insert or update on xxont_oe_order_lines_vw
    referencing
    new as new
    old as old
    for each row
    declare
       zero_update exception;
    begin
       update oe_order_lines_all
          set attribute7 = :new.attribute7
        where attribute18 = to_char(:new.header_id)
          and attribute17 = to_char(:new.line_id)
          and flow_status_code <> 'CANCELLED' ;
       if sql%rowcount = 0 then
         raise zero_update;
       end if;
    exception
      when zero_update then
         raise_application_error
               -20001
             , 'OE_ORDER_LINES_ALL: 0 rows updated attribute18 = "'
               || attribute18
               || '" attribute17 = "'
               || to_char(:new.line_id)
               || '"'
    end ;
    This will help you raise error when the update does not update any row. This is just an example, make sure if this is what your requirement wants if you want to implement it. If you don't want to raise error then you can just log it in a log table or log file.

  • PLEASE HELP!! Trigger on a view that updates a table synonym?

    I have a view (PERSONINFO_VIEW) that pulls user information from several ODS.CT tables. This view contains userid, first name, last name, telephone, and email. I'm trying to create a trigger that will insert these values into a remote table with a public synonym (PERSON_CTL_SYN) using a procedure. If I run the procedure alone, it works, and the table is updated. I enter data into the view (by adding a new user account to the portal) the PERSONINFO_VIEW is updated with the new information, but the trigger that calls the procedure doesn't seem to fire, because the PERSON_CTL_SYN is not updated.
    My trigger (PERSON_SYN_INS):
    On PTS.PERSONINFO_VIEW, INSTEAD OF EACH ROW, INSERT, ENABLED
    begin
    person_syn_ins_proc(:new.userid, :new.firstname, :new.lastname,:new.phone,:new.email);
    end;
    My Procedure (PERSON_SYN_INS_PROC):
    CUSER IN VARCHAR2,
    CFIRST IN VARCHAR2,
    CLAST IN VARCHAR2,
    CPHONE IN VARCHAR2,
    CEMAIL IN VARCHAR2
    as
    cSecrGrp varchar2(30) := 'ITSUSER';
    cLoc varchar2(30) := 'OUS-ITS';
    cArea varchar2(3) := '541';
    begin
    insert into person_ctl_syn(
    person_first_name,
    person_last_name,
    person_username,
    person_email,
    person_phone_number)
    values(
    cFirst,
    cLast,
    cUser,
    cEmail,
    cPhone);
    commit ;
    end;

    I have a view (PERSONINFO_VIEW) that pulls user information from several ODS.CT tables. This view contains userid, first name, last name, telephone, and email. I'm trying to create a trigger that will insert these values into a remote table with a public synonym (PERSON_CTL_SYN) using a procedure. If I run the procedure alone, it works, and the table is updated. I enter data into the view (by adding a new user account to the portal) the PERSONINFO_VIEW is updated with the new information, but the trigger that calls the procedure doesn't seem to fire, because the PERSON_CTL_SYN is not updated.
    My trigger (PERSON_SYN_INS):
    On PTS.PERSONINFO_VIEW, INSTEAD OF EACH ROW, INSERT, ENABLED
    begin
    person_syn_ins_proc(:new.userid, :new.firstname, :new.lastname,:new.phone,:new.email);
    end;
    My Procedure (PERSON_SYN_INS_PROC):
    CUSER IN VARCHAR2,
    CFIRST IN VARCHAR2,
    CLAST IN VARCHAR2,
    CPHONE IN VARCHAR2,
    CEMAIL IN VARCHAR2
    as
    cSecrGrp varchar2(30) := 'ITSUSER';
    cLoc varchar2(30) := 'OUS-ITS';
    cArea varchar2(3) := '541';
    begin
    insert into person_ctl_syn(
    person_first_name,
    person_last_name,
    person_username,
    person_email,
    person_phone_number)
    values(
    cFirst,
    cLast,
    cUser,
    cEmail,
    cPhone);
    commit ;
    end;

  • Updating a table through a manually created tabular form does not work.

    Hi Friends,
    I don't know why the "On submit - After computations and validations" process does not update the referenced table. May I miss something. Here is my source :
    select
    apex_item.hidden(1,eqp_id) id,
    apex_item.hidden(2,tcs_tcs_id) tcs,
    apex_item.text(3,eqp_equip_name,50) name,
    apex_item.text(4,eqp_equip_ident,50) ident,
    apex_item.text(5,eqp_equip_type,15) type
    from equip_physical
    where tcs_tcs_id = :P1_TCS_ID
    and here is the process source
    FORALL i IN 1..apex_application.g_f01.count
    UPDATE equip_physical
    SET eqp_equip_name=apex_application.g_f03(i),
    eqp_equip_ident=apex_application.g_f04(i),
    eqp_equip_type=apex_application.g_f05(i)
    WHERE eqp_id=apex_application.g_f01(i);
    No error message is displayed and my success message associated to the process is displayed. But the modified text field value is erased and the database table is not updated.

    I'd call it a bug/missing feature.
    It appears that within a Basic report, sorting on a column created using APEX_ITEM.DATE_POPUP2() does not sort by date.
    I'd file this with Oracle Support and see what they say.
    Include a link to this thread and your workspace login information.
    I got something to work by: (probably not what you want.)
    using the C004 column directly. (I just added it to the SQL code)
    setting the column's attribute "Display As" to "Date Picker"
    setting the column's attribute "Number /Date Format" to DD-MM-YYYY
    I suspect: since you don't start with p_idx => 1, this column becomes "1" ==> g_f01
    MK

  • Issue with Instead of Trigger

    Hi everyone,
    I have a view v_test . Created one instead of trigger over it. When I try to insert over the view it is throwing an error like' ORA-00036: maximum number of recursive SQL levels (50) exceeded' . Please help me how to over come from this.
    Please find the below DDL Stmts;
    CREATE TABLE test (id NUMBER,
    name VARCHAR2(10 CHAR),
    sal NUMBER,
    dept_id NUMBER);
    CREATE OR REPLACE VIEW v_test
    IS
    SELECT * FROM test;
    Trigger Code:
    CREATE OR REPLACE TRIGGER TR_V_TEST
    INSTEAD OF INSERT ON V_test
    FOR EACH ROW
    BEGIN
    INSERT INTO V_test VALUES(107,'VEERA',20000,30);
    END;
    Thanks in Advance !!
    Thanks,
    Vissu....

    Vissu,
    One and main scenario of mutating table error is depicted by your code only. You have created instead of Insert Trigger on view, within which again you are trying to insert on the same view i.e. you are trying to perform DML on a view which is already under transition state.
    Actually, Oracle tries hard to do the task. No of attempts is the value specified for "session_cached_cursors" (which is 50 here), but fails finally to recognise the table/view state, so throws the exception ORA-00036.
    In your case, instead of trigger was not required. You must understand the purpose of Instead of triggers. They are used when Multiple Tables build a view, and a DML on the view required data insertion in multiple tables. In above case, only one table is involved, so instead of trigger is not required. DML on your view can insert only in TEST table.
    But in above case, handle this by avoiding the DML(Insert) on the view inside the instead of insert trigger.
    Your purpose by insert on the view is to insert into TEST table only. So inside Instead of trigger,you can directly insert into table.
    Hope it is clear now !!

  • Trigger and Update Flag Table

    I've recently started trying to automate around a dozen procedures. These procedures are set to run immediately after the necessary previous procedure(s) is(are) done.
    What I am attempting to accomplish is a single generic trigger that will fire off each procedure when its parent procedures have finished firing. This will be accompanied by an update_flag table with three columns
    PARENT_PRC----------------------CHILD_PRC----------------------FLAG
    parent_prc_name1--------------child_prc_name1-----------------N
    parent_prc_name1--------------child_prc_name2-----------------N
    parent_prc_name3--------------child_prc_name3-----------------Y
    Logic:
    *1.*     When a procedure fires it updates this table to set any rows in which it is the “PARENT_PRC” by updating the FLAG column to = Y.
    *2.*     The trigger will execute a child procedure if its flag (or in the case of multiple parent procedures; all of its flags) are set to 'Y'. This trigger is set to fire AFTER a table update on the UPDATE_FLAG table.
    ----a.     I have to execute the procedure UFLAG in a job because I want the trigger to execute the procedure and then continue running immediately, rather than wait for the procedure to finish then commit. This way the trigger could start several procedures all running at the same time.
    ----b.     I have made it an autonomous transaction because I needed the job to fire immediately rather than be queued, which required a commit within the trigger.
    *3.*     The last step is to set the flag in UPDATE_FLAGS back to 'N' for CHILD_PRC = '||uflag||' once the child procedure is complete.
    ----a.     I have tried placing the update child_prc = 'N' in the trigger but it won’t allow a trigger that fires on update to update the same table.
    ----b.     I want to avoid putting the update statement in all of my procedures because I would like the option of running these procedures manually for testing purposes WITHOUT effecting the update_flags table.
    Number 3. is the key problem I have been having. Placing code within the trigger to update the update_flags table setting 'Y's back to 'N's once the procedures have fired causes a deadlock error.
    I believe this is simply because the trigger is attempting to update a table which (upon updating) causes the same trigger to fire before it has finish executing.
    How can I update the Flag table to reset the update flags back to 'N'?
    Is there a different way of doing this all together?
    Here is some code with dummy procedures that demonstrates what I have so far.
    With this code, executing parent procedures should set the update_flag table to 'Y' for FLAG where procedure = 'parent_prc'.
    I need to find a way to execute the child procedures AND set the FLAG column back to 'N' from the trigger.
    ex. executing parent_1 should set update_flags.flag = 'Y' where parent_prc = 'parent_1' and thus execute procedure CHILD_A and CHILD_B.
    create table update_flags (parent_prc varchar2(10), child_prc varchar2(10), flag varchar2(1));
    insert into update_flags values('parent_1', 'child_a', 'N');
    insert into update_flags values('parent_1', 'child_b', 'N');
    insert into update_flags values('parent_2', 'child_c', 'N');
    insert into update_flags values('parent_3', 'child_c', 'N');
    insert into update_flags values('parent_4', 'child_d', 'N');
    CREATE OR REPLACE procedure parent_1 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_1';
    END parent_1;
    CREATE OR REPLACE procedure parent_2 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_2';
    END parent_2;
    CREATE OR REPLACE procedure parent_3 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_3';
    END parent_3;
    CREATE OR REPLACE procedure parent_4 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_4';
    END parent_4;
    CREATE OR REPLACE procedure child_a as
    BEGIN
    dbms_output.PUT_LINE('CHILD_A Worked');
    commit;
    END child_a;
    CREATE OR REPLACE procedure child_b as
    BEGIN
    dbms_output.PUT_LINE('CHILD_B Worked');
    commit;
    END child_b;
    CREATE OR REPLACE procedure child_c as
    BEGIN
    dbms_output.PUT_LINE('CHILD_C Worked');
    commit;
    END child_c;
    CREATE OR REPLACE procedure child_d as
    BEGIN
    dbms_output.PUT_LINE('CHILD_D Worked');
    commit;
    END child_d;
    CREATE OR REPLACE TRIGGER MASTER_TRG
    AFTER UPDATE
    ON UPDATE_FLAGS
    DECLARE
    Pragma  AUTONOMOUS_TRANSACTION;
    BEGIN
      DECLARE
      job_num number;
      uflag varchar2(1000);
      BEGIN
            select  MAX(case when COUNT(case when flag='Y' then 1 end)=COUNT(*) then CHILD_PRC else '  ' end)
            into uflag
            from        update_flags
            group by    child_prc;
            IF   uflag <> '  ' THEN
                                      --update update_flags set  flag = 'N' where child_prc = uflag     --(line of code that causes deadlock error)
                            dbms_job.submit (job => job_num,
                            what => ' '||uflag||';'
            END IF; 
       END;            
    COMMIT;
    END MASTER_TRG;
    execute parent_2;
    execute parent_3;

    >
    I think I am getting my head around the transactional/trigger issue.
    >
    It doesn't sound like it since you are still talking 'triggers'. At any rate it is OP that needs to get their head around it.
    OP doesn't even know what the entire process needs to be but has already decided that
    1. a single generic trigger that will fire off each procedure when its parent procedures have finished firing
    2. an update_flag table with three columns: PARENT_PRC, CHILD_PRC, FLAG
    3. a procedure fires it updates this table to set any rows in which it is the “PARENT_PRC” by updating the FLAG column to = Y.
    4. a job - I have to execute the procedure UFLAG in a job
    5. I have made it an autonomous transaction because I needed the job to fire immediately rather than be queued, which required a commit within the trigger.
    6. there should be an option of running these procedures manually for testing purposes WITHOUT effecting the update_flags table.
    Fortunately OP had the wisdom to ask
    >
    Is there a different way of doing this all together?
    >
    Doesn't anyone design things anymore? Seems like everyone just wants to decide what the solution ought to be be and then try to force the problem to fit into it.
    The first stage is the DESIGN - not the implementation details or technology to use.
    The first design step is to outline, or flowchart, the PROCESS that needs to take place. Since OPs post lacks sufficient detail I will substitute my own 'guesstimations' to illustrate.
    1. there are one or more 'parent' processes
    2a. these parent processes are allowed to run in parallel as they do not interfere in any way with the processing done by other parent or child processes. (is this true?)
    2b. these parent processes ARE NOT allowed to run in parallel as they may interfere with each other.
    3. Each parent process can have one or more 'child' processes. (it appears that these aren't really children but rather processes that are 'dependent' on the parent or that must always be executed after, and each time that the parent executes.
    So here are just SOME of the things that are missing that must be known before possible alternatives can be explored
    1. Re item #2 - can the parent processes be executed in parallel? Or must they be executed serially? Will any of the parent processes be dependent on any other parent or child process?
    2. What is the relationship between a parent process and its child processes? Is the parent always executed first? What triggers the parent execution? How often is it executed?
    What if it is already executing? What if other parent processes are currently executing? What if one or more of its child processes are executing? What if the parent process fails for any reason - what action should be taken?
    Based on what was posted a set of parent and child processes might need nothing more than: execute parent, execute child1, execute child2, . . ., execute childn.
    3. What is the relationship between the child processes that belong to the same parent? Can they be executed in parallel (i.e. are they completely independent)? Or must they be executed in some particular order? What if one or more of the child processes fails for any reason - what action should be taken?
    4. Will any other user or process be executing these parent or child processes? That could interfered with the automated stream.
    5. What type of exception handling and recovery needs to be implemented in one or more steps of the processing fail for some reason?
    Typically there is often one or more control tables (OPs flag table) to control and limit the processing. But the table would have status information for every process not just the children:
    A. STATUS - DISABLED, ACTIVE, RUNNING, IDLE, ERROR
    B. START_TIME
    C. END_TIME
    D. RESULT_CODE
    The control table can be used by a parent or child process to determine if it is permitted to run. For example the first thing a procedure might do is check it's own STATUS. If it is already running it would exit or log an error or message. If that test is passed it might check the status of any dependent processes. For example it might check that its child processes are ACTIVE and ready to run; if a child was still running the parent would exit or log an error or message.
    The control process would lock the appropriate control table records (FOR UPDATE) and would set the status and other fields appropriately to prevent interference by other processes or procedures.
    Design first. Then look at the implementation options.

  • Creating an Updateable View with Key Preservable Tables

    Hello everyone,
    I'm trying to create a view of two tables that I have in order to perform an instead of trigger on said view. The table structures for the tables I am using are as follows:
    Project Tasks Table
    TASK_ID  (Primary Key)
    TASK_NAME
    TASK_DUE_DATE
    Task Assignments Table
    ASSIGNMENT_ID (Primary Key)
    TASK_ID (Foreign Key)
    USER_ID
    ASSET_ID
    Given that, I'd like to create a view of a left outer join of the tables, so that every task is shown, regardless of whether or not it is assigned to someone. I've successfully created the view, which can be seen here:
    select
    P.TASK_ID,
    P.TASK_DUE_DATE,
    P.TASK_NAME,
    TA.ASSET_ID,
    TA.USER_ID
    from PROJECT_TASKS P
         left outer join PROJECT_TASK_ASSIGNMENTS TA
        on P.PROJECT_TASKS.TASK_ID = TA.PROJECT_TASK_ASSIGNMENTS.TASK_ID;
    I have also created a trigger on this view, to update both tables on an insert to the view. However, I cannot execute the trigger as when I check if the columns are user updateable, it shows NO for all of them. Is there any way I can create a view on these tables that allows for every column to be UPDATEABLE, INSERTABLE and DELETABLE?

    Hi,
    If you're writing an INSTEAD OF trigger, then it doesn't matter if anything in the view is updateable, insertable, deleteable or whatnotable.  Do all DML operations directly on the base tables.
    If you have problems, then post a complete test script that the peope who want to help you can run to re-create the problem and test their ideas.  Include CREATE TABLE and INSERT statements for you base tabels, the CREATE VIEW statement (if not exactly what you already posted), your best attempt at a CREATE TRIGGER statement, and some code that tests it.  Explain what results you want from that test (that is, what the tables should contain after it finishes.)
    Start small and take baby steps.  Start with a trigger that, say, only DELETEs.  When we get that working, then we can change iot to handle INSERTs.

  • Issue in Invoking an Updatable View with Instead of Trigger

    Hi,
    I am trying to insert a record using Updatable View with Instead of Trigger. When i try to save the data, i get the below error:
    java.sql.SQLException: ORA-01403: no data found
    ORA-06512: at line 1
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:213)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1075)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1466)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3752)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3887)
    at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:9323)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1508)
    at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:172)
    at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:432)
    at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:8566)
    Can someone help me resolve this issue?
    Also it would be great if you can share Sample codes for Invoking an updatable view with instead of trigger on Save/commit.
    Regards,
    Jeevan

    As a trigger is executed in the db and not in your app it's really hard to help as you did not give any useful information.
    Have you read this blog http://stegemanoracle.blogspot.com/2006/03/using-updatable-views-with-adf.html ?
    Timo
    Edited by: Timo Hahn on 22.09.2011 09:15
    And my friend google also found http://technology.amis.nl/blog/1447/adf-business-components-resfresh-after-insertupdate-and-instead-of-triggers

  • View-Update in forms with Instead-Of trigger

    I has created a view and an Instead-Of trigger on that view.
    Now, I want to update this view in FORMS 6. I am unable to update this view and getting error FRM-40602.
    Is there any way to update this view updatable in FORMS6 or FORMS6 has not this feature?

    Hi,
    This has been acknowledged by Oracle as bug earlier. The work-around for this is as follows:
    1. Create table 1
    2. Create table 2
    3. Create view
    4. Create instead of insert trigger on view
    5. Create instead of update trigger on view
    6. Now, in the forms, go to the Block property
    7. Look for the 'Key mode' property. By default it is 'Automatic'. Set it to Updateable (If your database design supports updating primary keys) or Unique (preferable).
    8. Now run the form. It should work.
    All the best.
    Sunil Kumar G S

  • ADF BC: Creating updatable VO based upon DB View with "instead of" trigger

    Hello all,
    I have got an interesting issue. I have an Oracle DB view that is used to hide some complexity in the underlying DB design (it does some unions). This view is updatable because we have created an "instead of" update trigger to update the correct table when a row is updated. This is working fine in SQL.
    Next, we have created an ADF Entity object based upon the view, specifying an appropriate PK for the DB View. Then, we have created an updatable VO based upon the EO. All well and good so far. The issue we have is in trying to commit changes to the DB - because the ADF BC framework is trying to lock the row to update (using SELECT ... FOR UPDATE), it's not working because of ORA-02014 - cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
    This leads me to thinking about overridding doSelect() on the EO as hinted here http://radio.weblogs.com/0118231/stories/2005/07/28/differenceBetweenViewObjectSelectAndEntityDoselectMethod.html
    As a temporary test, we have over-ridden the EO's doSelect to call super.doSelect(false) and it does work, although we will have lost update issues as detailed in Steve's article.
    My questions:
    1). Is overriding doSelect() the correct thing here? Perhaps there is a better way of handling this problem? I do have a base EO class from which all of the EO's extend, so adding this behavior should be straightforward.
    2). Does anyone have example doSelect implementation? I am thinking of overriding doSelect for my EO and calling super.doSelect (lock=false), but then I need to deal with some possible exceptions, no?
    Kind regards,
    John

    Hi John,
    I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
    My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
    In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
    Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
    Many thanks,
    Dave
    London

  • Instead of trigger example - INSERT works but UPDATE and DELETE does not?

    Below is a demostration script of what I am trying to troubleshoot. Tests are done on 10gR2;
    conn system/system
    drop table tt purge ;
    create table tt nologging as select * from all_users ;
    alter table tt add constraint pk_tt_user_id primary key (user_id) nologging ;
    analyze table tt compute statistics for table for all indexed columns ;
    conn hr/hr
    drop database link dblink ;
    create database link dblink
    connect to system identified by system
    using 'xe.turkcell' ;
    select * from global_name@dblink ;
    drop view v_tt ;
    create view v_tt as select username, user_id, created from tt@dblink order by 2 ;
    select count(*) from v_tt ;
    COUNT(*)
    13
    drop sequence seq_pk_tt_user_id ;
    create sequence seq_pk_tt_user_id
    minvalue 1000 maxvalue 99999
    increment by 1;
    create synonym tt for tt@dblink ;
    CREATE OR REPLACE PROCEDURE prc_update_tt(old_tt v_tt%ROWTYPE, new_tt v_tt%ROWTYPE) IS
    BEGIN
    IF old_tt.user_id != new_tt.user_id THEN
    RETURN; -- primary key
    END IF;
    IF old_tt.user_id IS NOT NULL AND new_tt.user_id IS NULL THEN
    DELETE FROM tt
    WHERE user_id = nvl(old_tt.user_id,
    -99);
    RETURN;
    END IF;
    IF (old_tt.username IS NULL AND new_tt.username IS NOT NULL) OR
    (old_tt.username IS NOT NULL AND new_tt.username != old_tt.username) THEN
    UPDATE tt
    SET username = new_tt.username
    WHERE user_id = nvl(old_tt.user_id,
    -99);
    END IF;
    IF (old_tt.created IS NULL AND new_tt.created IS NOT NULL) OR
    (old_tt.created IS NOT NULL AND new_tt.created != old_tt.created) THEN
    UPDATE tt
    SET created = new_tt.created
    WHERE user_id = nvl(old_tt.user_id,
    -99);
    END IF;
    END prc_update_tt;
    CREATE OR REPLACE PROCEDURE prc_insert_tt(old_tt v_tt%ROWTYPE, new_tt v_tt%ROWTYPE) IS
    new_tt_user_id NUMBER;
    BEGIN
    SELECT seq_pk_tt_user_id.NEXTVAL INTO new_tt_user_id FROM dual;
    INSERT INTO tt
    (username, user_id, created)
    VALUES
    (new_tt.username, new_tt_user_id, new_tt.created);
    END prc_insert_tt;
    CREATE OR REPLACE PROCEDURE prc_delete_tt(old_tt v_tt%ROWTYPE, new_tt v_tt%ROWTYPE) IS
    BEGIN
    DELETE FROM tt
    WHERE user_id = nvl(old_tt.user_id,
    -99);
    END prc_delete_tt;
    CREATE OR REPLACE TRIGGER trg_iof_v_tt
    INSTEAD OF UPDATE OR INSERT OR DELETE ON v_tt
    FOR EACH ROW
    DECLARE
    new_tt v_tt%ROWTYPE;
    old_tt v_tt%ROWTYPE;
    BEGIN
    dbms_output.put_line('INSTEAD OF TRIGGER fired');
    dbms_output.put_line(':NEW.user_id ' || :NEW.user_id);
    dbms_output.put_line(':OLD.user_id ' || :OLD.user_id);
    dbms_output.put_line(':NEW.username ' || :NEW.username);
    dbms_output.put_line(':OLD.username ' || :OLD.username);
    dbms_output.put_line(':NEW.created ' || :NEW.created);
    dbms_output.put_line(':OLD.created ' || :OLD.created);
    new_tt.user_id := :NEW.user_id;
    new_tt.username := :NEW.username;
    new_tt.created := :NEW.created;
    old_tt.user_id := :OLD.user_id;
    old_tt.username := :OLD.username;
    old_tt.created := :OLD.created;
    IF inserting THEN
    prc_insert_tt(old_tt,
    new_tt);
    ELSIF updating THEN
    prc_update_tt(old_tt,
    new_tt);
    ELSIF deleting THEN
    prc_delete_tt(old_tt,
    new_tt);
    END IF;
    END trg_iof_v_tt;
    set serveroutput on
    set null ^
    insert into v_tt values ('XXX', -1, sysdate) ;
    INSTEAD OF TRIGGER fired
    :NEW.user_id -1
    :OLD.user_id
    :NEW.username XXX
    :OLD.username
    :NEW.created 30/01/2007
    :OLD.created
    1 row created.
    commit ;
    select * from v_tt where username = 'XXX' ;
    USERNAME USER_ID CREATED
    XXX 1000 31/01/2007          <- seems to be no problem with insert part but
    update v_tt set username = 'YYY' where user_id = 1000 ;
    INSTEAD OF TRIGGER fired
    :NEW.user_id
    :OLD.user_id
    :NEW.username YYY
    :OLD.username
    :NEW.created
    :OLD.created
    1 row updated.
    commit ;
    select count(*) from v_tt where username = 'YYY' ;
    COUNT(*)
    0               <- here is my first problem with update part, Oracle said "1 row updated."
    delete from v_tt where user_id = 1000 ;
    INSTEAD OF TRIGGER fired
    :NEW.user_id
    :OLD.user_id
    :NEW.username
    :OLD.username
    :NEW.created
    :OLD.created
    1 row deleted.
    commit ;
    select count(*) from v_tt ;
    COUNT(*)
    14               <- here is my second problem with delete part, Oracle said "1 row deleted."
    Any comments will be welcomed, thank you.
    Message was edited by:
    TongucY
    changed "-1" values to "1000" in the where clause of delete and update statements.
    it was a copy/paste mistake, sorry for that.

    What table do you process in your procedures ? You don't use DBLINK to
    reference remote table in your procedures.
    Seems, you have table "TT" in "HR" schema too.
    Look:
    SQL> create table tt nologging as select * from all_users where rownum <=3;
    Table created.
    SQL> select * from tt;
    USERNAME                          USER_ID CREATED
    SYS                                     0 25-APR-06
    SYSTEM                                  5 25-APR-06
    OUTLN                                  11 25-APR-06
    SQL> conn scott/tiger
    Connected.
    SQL> create database link lk65 connect to ... identified by ... using 'nc65';
    Database link created.
    SQL> select * from tt@lk65;
    USERNAME                          USER_ID CREATED
    SYS                                     0 25-APR-06
    SYSTEM                                  5 25-APR-06
    OUTLN                                  11 25-APR-06
    SQL> create view v_tt as select username, user_id, created from tt@lk65 order by 2;
    View created.
    SQL> select * from v_tt;
    USERNAME                          USER_ID CREATED
    SYS                                     0 25-APR-06
    SYSTEM                                  5 25-APR-06
    OUTLN                                  11 25-APR-06
    SQL> create sequence seq_pk_tt_user_id
      2  minvalue 1000 maxvalue 99999
      3  increment by 1;
    Sequence created.
    SQL> CREATE OR REPLACE PROCEDURE prc_insert_tt(old_tt v_tt%ROWTYPE, new_tt v_tt%ROWTYPE) IS
      2  new_tt_user_id NUMBER;
      3  BEGIN
      4  SELECT seq_pk_tt_user_id.NEXTVAL INTO new_tt_user_id FROM dual;
      5  INSERT INTO tt
      6  (username, user_id, created)
      7  VALUES
      8  (new_tt.username, new_tt_user_id, new_tt.created);
      9  END prc_insert_tt;
    10  /
    Warning: Procedure created with compilation errors.
    SQL> show error
    Errors for PROCEDURE PRC_INSERT_TT:
    LINE/COL ERROR
    5/1      PL/SQL: SQL Statement ignored
    5/13     PL/SQL: ORA-00942: table or view does not exist
    SQL> edit
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PROCEDURE prc_insert_tt(old_tt v_tt%ROWTYPE, new_tt v_tt%ROWTYPE) IS
      2  new_tt_user_id NUMBER;
      3  BEGIN
      4  SELECT seq_pk_tt_user_id.NEXTVAL INTO new_tt_user_id FROM dual;
      5  INSERT INTO tt@lk65
      6  (username, user_id, created)
      7  VALUES
      8  (new_tt.username, new_tt_user_id, new_tt.created);
      9* END prc_insert_tt;
    SQL> /
    Procedure created.Rgds.

Maybe you are looking for