Instead of Update Trigger error

Hi all,
I've been trying to solve this issue from past 4 to 5 days..I am unable to solve...Can someone please help....
I hhave a requirement in which I need to update 4 tables from a single form...I created a view which will get the required fields along with the primary keys from all these 4 tables.
Then I created a Instead of Update trigger as below
CREATE OR REPLACE TRIGGER "HOMEPAGEVIEW_UPDATE"
INSTEAD OF UPDATE ON cts_homepageview
BEGIN
DECLARE
vID NUMBER;
UPDATE cts_hardware_info
SET STATUS_ID = :NEW.STATUS_ID,
COMPUTER_NAME = :NEW.COMPUTER_NAME,
OPERATINGSYSTEM_ID = :NEW.OPERATINGSYSTEM_ID
where computer_id = :NEW.COMPUTER_ID;
UPDATE cts_server_administrator
SET PRIMARY_ADMIN_ID = :NEW.PRIMADMIN_ID,
SECONDARY_ADMIN_ID = :NEW.SECONDADMIN_ID
WHERE ID = :NEW.ID;
UPDATE cts_location_info
SET BUILDING_ROOM_RACK = :NEW.BUILDING_ROOM_RACK
WHERE LOCATION_ID = :NEW.LOCATION_ID;
UPDATE cts_maintenace_info
SET MAINTENANCE_WINDOW = :NEW.MAINTENANCE_WINDOW
WHERE MAINTENANCE_ID = :NEW.MAINTENANCE_ID;
END;
When I try to update a record, am gettting the following error
ORA-20505: Error in DML: p_rowid=488, p_alt_rowid=COMPUTER_ID, p_rowid2=, p_alt_rowid2=. ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
Error Unable to process row of table CTS_HOMEPAGEVIEW.
OK
I have already posted this question on the forum, but dint get any replies so trying my luck again....Can someone plzzzzzz help...I searched on ths forum for similar requests...Found one post bt hte solution wasnt given...
Thanks,
Shravanthi
Edited by: user0012 on Apr 29, 2009 9:54 AM

Hi Varad and Andy,
Thank you both for your responses first..I was soo tensed since no one replied to my previous post fr 5 days..
Varad,
With the change Andy told ('Begin & END'), I tried in SQL Workshop updated computer_name (of cts_hardware_info) data in the view..It updated the data. But from the form, it is still giving the same error.
Andy,
Here is my view.. All the table are associated with the cts_hardware_info using computer_id. And using this computer_id I have put all the data together.
CREATE OR REPLACE FORCE VIEW "CTS_HOMEPAGEVIEW" ("COMPUTER_ID", "COMPUTER_NAME", "STATUS_ID", "DESCRIPTION", "OPERATINGSYSTEM_ID", "ID", "PRIMADMIN_ID", "PRIMARYADMIN_PHONE1", "SECONDADMIN_ID", "SECONDARYADMIN_PHONE1", "LOCATION_ID", "BUILDING_ROOM_RACK", "MAINTENANCE_ID", "MAINTENANCE_WINDOW") AS
select g.computer_id,g.computer_name,g.status_id,cts_hardware_status.DESCRIPTION,g.operatingsystem_id,g.id,g.PrimAdmin_ID,g.PrimaryAdmin_Phone1,g.SecondAdmin_ID, g.SecondaryAdmin_PHONE1,g.location_id,g.BUILDING_ROOM_RACK,g.MAINTENANCE_ID,g.MAINTENANCE_WINDOW from
(select e.computer_id,e.computer_name,e.status_id,e.operatingsystem_id,e.id,e.PrimAdmin_ID,e.PrimaryAdmin_Phone1,e.SecondAdmin_ID,e.SecondaryAdmin_PHONE1,
e.location_id,e.BUILDING_ROOM_RACK,f.MAINTENANCE_ID,f.MAINTENANCE_WINDOW from
(select c.computer_id,c.computer_name,c.status_id,c.operatingsystem_id,c.id,c.PrimAdmin_ID,c.PrimaryAdmin_Phone1,c.SecondAdmin_ID,c.SecondaryAdmin_PHONE1,
d.location_id,d.BUILDING_ROOM_RACK from
(select a.computer_id,a.computer_name,a.status_id,a.operatingsystem_id,b.id,b.PrimAdmin_ID,b.PrimaryAdmin_Phone1,b.SecondAdmin_ID,b.SecondaryAdmin_PHONE1 from
(select cts_hardware_info.computer_id,cts_hardware_info.computer_name,cts_hardware_info.status_id,operatingsystem_id from cts_hardware_info) a
left join
(select cts_server_administrator.id,cts_server_administrator.computer_id,cts_administrator_contacts.ADMIN_id as PrimAdmin_ID,Phone1 as PrimaryAdmin_Phone1,
(select ADMIN_id from cts_administrator_contacts where admin_id = CTS_Server_Administrator.Secondary_ADMIN_ID) as SecondAdmin_ID,
(select Phone1 from cts_administrator_contacts where admin_id = CTS_Server_Administrator.Secondary_ADMIN_ID) as SecondaryAdmin_PHONE1
from cts_server_administrator,cts_administrator_contacts where cts_administrator_contacts.admin_id = cts_server_administrator.PRIMARY_ADMIN_ID) b
on a.computer_id = b.computer_id) c
left join
(select location_id,COMPUTER_ID,BUILDING_ROOM_RACK from cts_location_info) d
on c.computer_id = d.computer_id) e
left join
(select MAINTENANCE_ID,COMPUTER_ID,MAINTENANCE_WINDOW from CTS_MAINTENACE_INFO) f
on e.computer_id = f.computer_id) g left join cts_hardware_status on g.status_id = cts_hardware_status.STATUS_ID

Similar Messages

  • ApEx 4.1.1: update record in a view with 'instead of update' trigger

    I created a form against a view. The view is complex enough which prevents direct updates. To incorporate the update logic I created an 'instead of update' trigger on the view. When I open up the form, do changes, and click 'Apply Changes' button I am getting the following exception
    ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
    I understand that the standard 'Automatic Row Processing' process is trying to lock the record before updating using a cursor like
    select *
    from my_view
    for update
    and fails. Is it possible to bypass this locking while using the standard APEX processes?
    I think I can create a custom PL/SQL process which would execute the UPDATE statement (at least, it works in SQL*Plus), but I would like to know if I can use a standard ApEx functionality for this.

    Hello,
    Sorry for delay.
    I had found a feedback about trigger issue when restore SQL Database from a BACPAC file. Microsoft said the fixed  will be available in the next major release of DacFx.
    Feedback:
    SQL Azure fires a trigger when restoring from bacpac
    You can refer to the workarounds in the feedback. For example, if there is small amount of triggers on the database, you can try to remove the triggers and then recreate when restore from bacpac file.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Instead of update trigger

    Hi
    I have a view, I like to create a update form for.
    Someone have a sample how to use a "instead of update trigger" with a form?
    I would like to have a report with a column link to the form, and the form use a "instead of update trigger" to update the row.
    Best Regrads
    Jesper Vels

    Hi Jesper,
    <p>I'm not sure I understand your problem correctly but I'll have a go nevertheless.</p>
    <p>I think you can accomplish this with standard out of the box apex functionality. </p>
    <p>You can create your report with a link to your data entry form which has auto DML functionality built in. I do not understand the need for an update trigger, based on what you have said. </p>
    <p>I think this link will give you an idea how how to accomplish the functionality your looking for.</p>
    <p>Otherwise In version 2.0 (the only version I have access to at the moment - though should be the same in 2.2). Create a new page of type form and specify "Form on a Table with Report" in the next stage of the wizard. Work through the rest of the wizard and see whether what is generated fits your purpose or can easily be adapted to suite your purposes. </p>
    <p>Let me know how you get on.</p>
    <p>Regards
    Kris
    </p>
    Regards Kris

  • Update trigger error

    Hello,
    I have this issue where I'm getting the following error when executing an update in a view. Insert command appears to be OK. Any idea on what am I missing?
    ORA-01084: invalid argument in OCI call
    ORA-06512: at "APPS.XXRVM_TEMP_B_UPD_TR", line 2
    ORA-04088: error during execution of trigger 'APPS.XXRVM_TEMP_B_UPD_TR'
    -- sample update statement:
    update xxrvm_temp_b_v
    set text1 = 'ddd'
    where text1 = 'aaa'
    Thanks,
    Rownald
    ----- object definitions ----
    -- Located in TEST1 Dbase
    create table xxrvm_temp_b
    (text1 varchar2(30)
    ,text2 varchar2(30)
    -- Located in TEST2 Dbase
    -- view definition based on table at dblink
    create or replace force view xxrvm_temp_b_v
    (pri_key, text1, text2) as select rowid pri_key, text1, text2 from xxrvm_temp_b@test1;
    -- trigger definition for insert
    create or replace trigger xxrvm_temp_b_ins_tr
    instead of insert on xxrvm_temp_b_v referencing new as new old as old
    for each row
    begin
    insert into xxrvm_temp_b@test1 (text1, text2)
    values (:new.text1, :new.text2);
    end;
    -- trigger definition for update
    create or replace trigger xxrvm_temp_b_upd_tr
    instead of update on xxrvm_temp_b_v referencing new as new old as old
    for each row
    begin
    update xxrvm_temp_b@test1
    set text1 = :new.text1 ,text2 = :new.text2
    where rowid = :new.pri_key;
    end;

    Hello:
    Check if the update works if you re-write the on-update trigger as-- trigger definition for update
    create or replace trigger xxrvm_temp_b_upd_tr
    instead of update on xxrvm_temp_b_v referencing new as new old as old
    for each row
    begin
    update xxrvm_temp_b@test1
    set text1 = :new.text1 ,text2 = :new.text2
    where text1=:old_text1 and text2=:old_text2
    end;Varad

  • Insert/Update Trigger error

    Hi all,
    What is wrong with my code?
    SQL> create or replace trigger interval_after_tr
    after insert or update on intervals
    for each row
    begin
    if ((:new.beginning) > (:new.ending)) then
    RAISE_APPLICATION_ERROR(-20061,’BEGINNING VALUE > ENDING VALUE IN THE SAME ROW’);
    elsif ((:new.ending) < (interval_package.pac_ending)) or ((:new.ending) <> (interval_package.pac_beginning))
    RAISE_APPLICATION_ERROR(-20061,’ENDING VALUE IS < ANY ENDING VALUE OR <> ANY OTHER BEGINNING VALUE’);
    elsif ((:new.beginning) > (interval_package.pac_beginning)) or ((:new.beginning) <> (interval_package.pac_ending))
    RAISE_APPLICATION_ERROR(-20061,’BEGINNING VALUE IS > ANY BEGINNING VALUE OR <> ANY OTHER ENDING VALUE’);
    else
    RAISE_APPLICATION_ERROR(-20061,’INSERTED BEGINNING/ENDING VALUE IS INVALID’);
    end if;
    end ;
    Trigger created.
    SQL> show err
    Errors for TRIGGER INTERVAL_AFTER_TR:
    LINE/COL ERROR
    3/42 PLS-00103: Encountered the symbol "?" when expecting one of the
    following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set
    specification>
    <an alternatively-q
    Kindly help!
    Regards,
    S.

    Try:
    CREATE OR REPLACE TRIGGER interval_after_tr
    AFTER INSERT OR UPDATE
    ON intervals
    FOR EACH ROW
    BEGIN
    IF ((:NEW.beginning) > (:NEW.ending))
    THEN
    raise_application_error
    (-20061,
    'BEGINNING VALUE > ENDING VALUE IN THE SAME ROW'
    ELSIF ((:NEW.ending) < (interval_package.pac_ending))
    OR ((:NEW.ending) <> (interval_package.pac_beginning))
    THEN
    raise_application_error
    (-20061,
    'ENDING VALUE IS < ANY ENDING VALUE OR <> ANY OTHER BEGINNING VALUE'
    ELSIF ((:NEW.beginning) > (interval_package.pac_beginning))
    OR ((:NEW.beginning) <> (interval_package.pac_ending))
    THEN
    raise_application_error
    (-20061,
    'BEGINNING VALUE IS > ANY BEGINNING VALUE OR <> ANY OTHER ENDING VALUE'
    ELSE
    raise_application_error (-20061,
    'INSERTED BEGINNING/ENDING VALUE IS INVALID'
    END IF;
    END;
    /

  • Before update trigger on a view

    Hello,
    is not possible to write a before update or insert trigger based on a view?
    create or replace trigger trg_bef_upd_vwangajatiabsente
    before update on vw_angajati_absente
    referencing old as old new as new
    for each row
    begin
    if :old.motivabila='N' and :new.motivabila='D' then raise_application_error(-20433, 'Nu se poate modifica o absenta nemotivabila!');
    end;is it possible to solve these situations? :)
    Regards,

    Roger22 wrote:
    regarding to 2)
    in my trigger i must raise_application_error? if i don't raise then i need to issue update statements..... ?If you have an INSTEAD OF trigger that just has a body similar to the body you posted above, that would mean that update statements either
    - Raise an error
    - Do nothing (i.e. do not update any data in any table)
    That is a syntactically valid state-- Oracle will certainly allow you to have an INSTEAD OF UPDATE trigger that effectively throws away update statements. It's just that it would be rather rare that this would be the desired behavior. Presumably, if you're going through the effort of writing the trigger, you want certain update statements to succeed and, thus, to update data. If that is the case, your trigger would have to have UPDATE statements that update the proper row(s) in the proper base table(s).
    An INSTEAD OF UPDATE trigger is literally that. You are replacing, in its entirety, the update statement against the view with the code in your trigger. So your trigger would need to issue the base table updates that Oracle would have had there not been a trigger on the view.
    Justin

  • Error when a try to update a xmltype view thru a trigger instead of update

    <PERSON>
    <ID>4</ID>
    <FIRSTNAME>Frédéric</FIRSTNAME>
    <LASTNAME>Philippekin</LASTNAME>
    <SEX>M</SEX>
    <WEIGHT>75</WEIGHT>
    <HEIGHT>175</HEIGHT>
    </PERSON>
    CREATE OR REPLACE VIEW personne_oracle OF XMLType
    XMLSCHEMA "personOracle.xsd" ELEMENT "PERSON"
    WITH OBJECT ID (EXTRACT(sys_nc_rowinfo$, '/PERSON/ID').getNumberVal())
    AS SELECT XMLELEMENT("PERSON",
              XMLFOREST( Id,
    FirstName,
    LastName,
    Sex,
    Weight,
              Height)
    ) AS Valeur     
    FROM Person;
    CREATE OR REPLACE TRIGGER u_personne_oracle_tr
    INSTEAD OF UPDATE on personne_oracle
    BEGIN
    UPDATE Person SET
    Person.FirstName = extractvalue(:new.sys_nc_rowinfo$,'/PERSON/FIRSTNAME/text()'),
    Person.LastName = extractvalue(:new.sys_nc_rowinfo$,'/PERSON/LASTNAME/text()'),
    Person.Weight = extractvalue(:new.sys_nc_rowinfo$,'/PERSON/WEIGHT/text()'),
    Person.Height = extractvalue(:new.sys_nc_rowinfo$,'/PERSON/HEIGHT/text()')
    WHERE Person.Id = extractvalue(:new.sys_nc_rowinfo$,'/PERSON/ID');
    END;
    UPDATE personne_oracle x
    SET value(x) = updateXML(value(x), '/PERSON/FIRSTNAME/text()','Fred')
    WHERE extractValue(value(x), '/PERSON/ID') = 4;
    ORA-24358: OCIBindObject not invoked for a Object type or Reference
    please help me !

    What happens if you move the view to the remote db?
    and create a synonym for the view on the local?it doesn't work !
    >
    alternatively,
    what happens if you modify from person@oraclelink in
    the create or replace view personne_oracle?it doesn't work !
    The problem is the dblink ! Without it it's work !
    thx for your answer.

  • Instead of Trigger Error

    Hi ALL,
    I am trying to create INSTEAD OF trigger on the existing VIEW, but I getting error as:-
    Not found
    The requested URL /apex/wwv_flow.show was not found on this server
    I'm creating trigger as :-
    CREATE OR REPLACE TRIGGER "trigger_name"
    INSTEAD OF UPDATE ON "view_name"
    FOR EACH ROW
    BEGIN
    UPDATE query;
    UPDATE query;
    END;
    but when I'm writting only one update query rather two update queires in the above trigger, it is creating but not with two update queries.
    Also I created another INSTEAD OF trigger on the same View as:-
    CREATE OR REPLACE TRIGGER "trigger_name"
    INSTEAD OF INSERT ON "view_name"
    FOR EACH ROW
    BEGIN
    INSERT query;
    INSERT query;
    END;
    this trigger is created without any errors than why INSTEAD OF(FOR UPDATE) trigger is not creating.... can anybody help me out with this issue.....
    thxs
    regards,
    Kumar

    Hi again,
    everything is working very much fine(I mean instead of trigger with update as well as with insert) when I'm creating on apex workspace.... this is the issue with my development enviornment.... so this is the problem with development DB or something else?????
    thxs
    regards,
    Kumar

  • DB Trigger error - Updating same table in the trigger script

    Hi All,
    I have a table tab1, when ever any update is done on this table on column col1 then col2 also need to get update.(These are linked to forms so user can update only col1 from form frontend)
    so I created a trigger as follows.
    CREATE OR REPLACE TRIGGER tri1
    AFTER UPDATE
    ON tab1
    FOR EACH ROW
    WHEN (NEW.col1 = 'YES')
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    UPDATE tab1 SET col2= 1
    WHERE transaction_id = :OLD.transaction_id;
    COMMIT;
    END;
    When there is any update on this table I get following error. Please let me know if I miss any thing.
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at "user1.tab1", line 5
    ORA-04088: error during execution of trigger 'user1.tab1'
    Please let me know if I am not clear. Thanks
    Edited by: DharV on Aug 23, 2011 5:17 AM

    Is your transaction_id unique?
    If that is the case then you could perhaps use BEFORE UPDATE instead of AFTER UPDATE:
    CREATE OR REPLACE TRIGGER tri1
    BEFORE UPDATE
    ON tab1
    FOR EACH ROW
    WHEN (NEW.col1 = 'YES')
    BEGIN
       :NEW.col2 := 1;
    END;If your transaction_id is not unique - so you really want to update more than one row in tab1 - your update cannot update the same row as the trigger reacted upon, even with the use of autonomous transaction. Then you could combine the above BEFORE UPDATE trigger with your own AFTER UPDATE, but then add ROWID != :OLD.ROWID to the where clause, but it would be a bad idea because some of your rows will be updated in one transaction and others in another transaction.
    In general autonomous transaction is not a great way to solve mutating table problem in a trigger. Hopefully you have a unique transaction_id and can do BEFORE UPDATE - if not then a better way is to save the id's to be updated in a package array in the FOR EACH ROW triggers, and then do a AFTER UPDATE trigger that is NOT "for each row" to update the list of saved id's.

  • Mutating Trigger error while updating table

    Hi Guys,
    I am updating one table and after trigger also fire at the same time. Now, I want to avoid mutating trigger error. Can any one help me on this.
    Thanks in advance!
    Regards,
    -LRK

    You'll have to read these articles first, they explain what's the problem and how to deal with it:
    http://www.oracle-base.com/articles/9i/MutatingTableExceptions.php
    http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551198119097816936
    but, as Saubhik already said, using Oracle's AUDIT functionality would be the way to go.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4007.htm
    Using an autonomous transaction can result in corrupted data or unexpected errors, stay away from them if you want to use them in order to bypass/hide your mutating table error.

  • Update trigger fails with value too large for column error on timestamp

    Hello there,
    I've got a problem with several update triggers. I've several triggers monitoring a set of tables.
    Upon each update the updated data is compared with the current values in the table columns.
    If different values are detected the update timestamp is set with the current_timestamp. That
    way we have a timestamp that reflects real changes in relevant data. I attached an example for
    that kind of trigger below. The triggers on each monitored table only differ in the columns that
    are compared.
    CREATE OR REPLACE TRIGGER T_ava01_obj_cont
    BEFORE UPDATE on ava01_obj_cont
    FOR EACH ROW
    DECLARE
      v_changed  boolean := false;
    BEGIN
      IF NOT v_changed THEN
        v_changed := (:old.cr_adv_id IS NULL AND :new.cr_adv_id IS NOT NULL) OR
                     (:old.cr_adv_id IS NOT NULL AND :new.cr_adv_id IS NULL)OR
                     (:old.cr_adv_id IS NOT NULL AND :new.cr_adv_id IS NOT NULL AND :old.cr_adv_id != :new.cr_adv_id);
      END IF;
      IF NOT v_changed THEN
        v_changed := (:old.is_euzins_relevant IS NULL AND :new.is_euzins_relevant IS NOT NULL) OR
                     (:old.is_euzins_relevant IS NOT NULL AND :new.is_euzins_relevant IS NULL)OR
                     (:old.is_euzins_relevant IS NOT NULL AND :new.is_euzins_relevant IS NOT NULL AND :old.is_euzins_relevant != :new.is_euzins_relevant);
      END IF;
    [.. more values being compared ..]
        IF v_changed THEN
        :new.update_ts := current_timestamp;
      END IF;
    END T_ava01_obj_cont;Really relevant is the statement
    :new.update_ts := current_timestamp;So far so good. The problem is, it works the most of time. Only sometimes it fails with the following error:
    SQL state [72000]; error code [12899]; ORA-12899: value too large for column "LGT_CLASS_AVALOQ"."AVA01_OBJ_CONT"."UPDATE_TS"
    (actual: 28, maximum: 11)
    I can't see how the value systimestamp or current_timestamp (I tried both) should be too large for
    a column defined as TIMESTAMP(6). We've got tables where more updates occur then elsewhere.
    Thats where the most of the errors pop up. Other tables with fewer updates show errors only
    sporadicly or even never. I can't see a kind of error pattern. It's like that every 10.000th update
    or less failes.
    I was desperate enough to try some language dependend transformation like
    IF v_changed THEN
        l_update_date := systimestamp || '';
        select value into l_timestamp_format from nls_database_parameters where parameter = 'NLS_TIMESTAMP_TZ_FORMAT';
        :new.update_ts := to_timestamp_tz(l_update_date, l_timestamp_format);
    END IF;to be sure the format is right. It didn't change a thing.
    We are using Oracle Version 10.2.0.4.0 Production.
    Did anyone encounter that kind of behaviour and solve it? I'm now pretty certain that it has to
    be an oracle bug. What is the forum's opinion on that? Would you suggest to file a bug report?
    Thanks in advance for your help.
    Kind regards
    Jan

    Could you please edit your post and use formatting and tags.  This is pretty much unreadable and the forum boogered up some of your code.
    Instructions are here: http://forums.oracle.com/forums/help.jspa                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Mutating error : row level BEFORE UPDATE trigger

    Hi,
    I had an issue on mutating terror(was trying to write a row level BEFORE update trigger), however i got it resolved after refering tom kytes web site. I thought i would share it with everyone, might be helpful for a few... Thanks!
    I will be more than happy to learn on further better ways of resolving this issue.
    Below I have posted the trigger that was causing this error and the work around for that issue, I created a package and three other triggers to replace row level BEFORE update trigger:
    ++trigger that was causing this issue:++
    CREATE OR REPLACE TRIGGER C_F_BI
    BEFORE INSERT ON CONTACT_FUNCTION FOR EACH ROW
    declare
    cursor function_code_cur ( cur_contact_id CONTACT.Contact_Id%type,
    cur_function_type_code CONTACT_FUNCTION.Function_Type_Code%type)
    is
    select
    cft.function_type_code,
    cft.multiples_permitted
    from
    CONTACT_FUNCTION cf,
    CONTACT c,
    CONTACT_FUNCTION_TYPE cft
    where
    c.acct_id = (select acct_id from contact where contact_id = cur_contact_id)
    and c.contact_id = cf.contact_id
    and cf.function_type_code = cft.function_type_code
    and cft.function_type_code = cur_function_type_code;
    v_function_type_code contact_function_type.function_type_code%type;
    v_multiples_permitted contact_function_type.multiples_permitted%type;
    E_Multiples_Not_Permitted Exception;
    begin
    if not function_code_cur%isopen then
    open function_code_cur(:new.contact_Id,:new.function_type_code);
    end if;
    loop
    fetch function_code_cur into v_function_type_code, v_multiples_permitted;
    exit when not function_code_cur%found;
    end loop;
    ** if the fetch returns a v_multiples_permitted of 'Y' or no record is found, then it is
    ** ok to add the record. Otherwise raise an error because that function_type is already
    ** being used at the current acct.
    if v_multiples_permitted = 'N' then
    raise E_Multiples_Not_Permitted;
    end if;
    close function_code_cur;
    EXCEPTION
    when E_Multiples_Not_Permitted then
    raise_application_error( -20001,'Multiples not allowed for function type ' ||
    v_function_type_code || '. sqlerrm - ' || sqlerrm );
    when others then
    raise;
    end;
    ++solution for above issue :++
    create or replace package state_pkg
    is
    type ridArray_rec is record(rid rowid, cont_id number, cont_fn_type varchar2(20));
    type ridArray is table of ridArray_rec index by binary_integer;
    newRows ridArray;
    empty ridArray;
    end state_pkg;
    create or replace trigger contact_function_bu1
    before update on contact_function
    begin
    state_pkg.newRows := state_pkg.empty;
    end;
    create or replace trigger contact_function_bu2
    before update ON CONTACT_FUNCTION FOR EACH ROW
    DECLARE
    I NUMBER:=0;
    begin
    I := state_pkg.newRows.count+1;
    state_pkg.newRows( I ).rid := :new.rowid;
    state_pkg.newRows( I ).cont_id := :new.contact_id;
    state_pkg.newRows( I ).cont_fn_type := :new.function_type_code;
    end;
    create or replace trigger contact_function_bu
    after update ON CONTACT_FUNCTION
    declare
    cursor function_code_cur ( cur_contact_id CONTACT.Contact_Id%type,
    cur_function_type_code CONTACT_FUNCTION.Function_Type_Code%type,
    rid2 rowid)
    is
    select
    cft.function_type_code,
    cft.multiples_permitted
    from
    CONTACT_FUNCTION cf,
    CONTACT c,
    CONTACT_FUNCTION_TYPE cft
    where
    c.acct_id = (select acct_id from contact where contact_id = cur_contact_id)
    and c.contact_id = cf.contact_id
    and cf.function_type_code = cft.function_type_code
    and cft.function_type_code = cur_function_type_code
    and cf.rowid = rid2;
    v_function_type_code contact_function_type.function_type_code%type;
    v_multiples_permitted contact_function_type.multiples_permitted%type;
    E_Multiples_Not_Permitted Exception;
    begin
    for i in 1 .. state_pkg.newRows.count loop
    if not function_code_cur%isopen then
    open function_code_cur(state_pkg.newRows(i).cont_id, state_pkg.newRows(i).cont_fn_type, state_pkg.newRows(i).rid);
    end if;
    loop
    fetch function_code_cur into v_function_type_code, v_multiples_permitted;
    exit when not function_code_cur%found;
    end loop;
    ** if the fetch returns a v_multiples_permitted of 'Y' or no record is found, then it is
    ** ok to add the record. Otherwise raise an error because that function_type is already
    ** being used at the current acct.
    if v_multiples_permitted = 'N' then
    raise E_Multiples_Not_Permitted;
    end if;
    close function_code_cur;
    end loop;
    EXCEPTION
    when E_Multiples_Not_Permitted then
    raise_application_error( -20001,'Multiples not allowed for function type ' ||
    v_function_type_code || '. sqlerrm - ' || sqlerrm );
    when others then
    raise;
    end;
    /

    It seems you could have solved the issue otherwise:
    CREATE OR REPLACE TRIGGER c_f_bi
       BEFORE INSERT
       ON contact_function
       FOR EACH ROW
    DECLARE
       v_function_type_code        contact_function_type.function_type_code%TYPE;
       v_multiples_permitted       contact_function_type.multiples_permitted%TYPE;
       e_multiples_not_permitted   EXCEPTION;
    BEGIN
       BEGIN
          SELECT cft.function_type_code, cft.multiples_permitted
            INTO v_function_type_code, v_multiples_permitted
            FROM contact c, contact_function_type cft
           WHERE c.acct_id = (SELECT acct_id
                                FROM contact
                               WHERE contact_id = :NEW.contact_id)
             AND c.contact_id = :NEW.contact_id
             AND cft.function_type_code = :NEW.function_type_code;
       EXCEPTION
          WHEN NO_DATA_FOUND
          THEN
             v_function_type_code := :NEW.function_type_code;
             v_multiples_permitted := '?';
       END;
    ** if the query returns a v_multiples_permitted of 'Y' or no record is found, then it is
    ** ok to add the record. Otherwise raise an error because that function_type is already
    ** being used at the current acct.
       IF v_multiples_permitted = 'N'
       THEN
          RAISE e_multiples_not_permitted;
       END IF;
    EXCEPTION
       WHEN e_multiples_not_permitted
       THEN
          raise_application_error (-20001,
                                      'Multiples not allowed for function type '
                                   || v_function_type_code
                                   || '. sqlerrm - '
                                   || SQLERRM
       WHEN OTHERS
       THEN
          RAISE;
    END;
    /:p

  • Instead of delete trigger rows deleted

    Hi All.
    Im using a few instead of triggers over a view. The view selects data from other tables and merges them together. This view essentially forms the parent of a few one2one relationships with other tables.
    However my application doesnt know its a view (im using hibernate orm framework) - so when I delete this object which is mapped to a view, I get an error saying that no records where deleted. Also, if i test in sqlplus, i get "0 rows deleted" in response to a delete - which of course is true, but i want it to say 1 or some number of my choice.
    How can i modify my "instead of delete" trigger so that the number for records deleted count returned to caller is 1, or some number i can define?
    Here is my current trigger...
    create or replace
    trigger product_view_delete_trigger
    instead of delete
    on product_view1
    for each row
    begin
    null;
    end;
    Thanks.

    In regards to why Im using a view - its discussed here...
    Crazy Union across 3 tables
    The view im using is not updatable - it uses a union. I use "instead of triggers" to trick my application into thinking its a real table which is insertable. And this works fine.
    Im having trouble tricking my application into think that the delete was successful, because the "instead of delete" trigger doesnt actually delete anything - which is what i wnat - but i want it to report back to the caller that a delete occurred.
    I want the SQL%ROWCOUNT to be set to 1 or whatever. Perhaps this is not hte variable, but im hoping there is some variable I can set which is used to report back to the client as to how many records were deleted.
    thx.

  • Halting the update from a BEFORE UPDATE trigger

    Hello,
    I'm writing a trigger which is set to fire before update. One of the possible scenarios requires that the row being updated is not updated but instead deleted. Is it possible to send a DELETE query and then stop the update process so it doesn't spit out an error? I haven't tested this yet, but I'm quite sure it will give an error if it's trying to update a row which has just been deleted.
    Thanks,
    Pavel

    Hi,
    Personally, I don't like implement some business logic into trigger... so, why run an update whenever you need a delete ?
    I would modify the original code to delete in this case instead of update.
    My 2 cents,
    Nicolas.
    SQL> create table pavel (id number, txt varchar2(10));
    Table created.
    SQL> insert into pavel values (1, 'This one');
    1 row created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace trigger pavel_trg
      2  before update on pavel
      3  for each row
      4  begin
      5  delete from pavel where id = :old.id;
      6* end;
    SQL> /
    Trigger created.
    SQL> update pavel set txt = 'Two';
    update pavel set txt = 'Two'
    ERROR at line 1:
    ORA-04091: table SCOTT.PAVEL is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.PAVEL_TRG", line 2
    ORA-04088: error during execution of trigger 'SCOTT.PAVEL_TRG'Message was edited by:
    N. Gasparotto

  • FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403

    FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403
    I am getting the above error when i am trying to change the Assignment Category field of
    an employee from Junior Staff to Senior Staff.
    Navigation People> Enter & Maintain> (B)Assignment.
    Kindly assist me to resolve this error.
    Plz note there is a promotion that is suppose to be given to some employees in our company as of
    01-APR-2010 so i had to open the closed payroll periods and do the changes. I managed to change for all
    the 9 employees but 1 employee's assignment is giving me an error as follows :
    FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403
    The error displays after i try to save the changes made to the Assignment Category from Junior Staff to Senior Staff.
    NB: i have also tried to switch off the custom code...but its giving me same error.
    Also the element links have been defined for employment category on the links window.
    please help!!
    Edited by: 594647 on Jul 20, 2010 10:26 PM

    Release 12.1.1.
    OS is Red Hat Ent Ed 4
    i am trying to change the employee assignment category from Junior to Senior. so when i am updating the assignment details on the assignment screen (Navigation is People >Enter & Maintain> Assignment) and trying to save, the system gives error on the status bar of the application as follows:
    FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403
    NB: Error is appearing on the Assignment screen.
    Please help!!
    Edited by: 594647 on Jul 21, 2010 2:48 PM

Maybe you are looking for

  • Creating a Fusion Drive ?

    Hi All, I have a mid-2011 iMac which I plan to install a Samsung 840 Pro SSD to use as part of a Fusion Drive setup. Typically I backup using Carbon Copy and wil be taking a backup prior to the mod. Once the drive has been configured......   will I n

  • DMVPN issue on a cisco 3845

    Hi all, We have configured a DMVPN from our headquarter to our branch offices (let's say BR1-BR3) . We have noticed that sometime we cannot access some of our branch office, the scenario is like this: - sometime, BR1 and BR2 are down but BR3 is worki

  • XP pro sp2 not installing - IO Error

    what's up mac gurus - I have one for you. I have a macbook pro -1.8ghz 2 gigs ram I just reformatted to a brand new tiger install with all the updates. I downloaded Bootcamp - which has worked fantastically for me I might add in the past. Anyhow in t

  • G5 HD output to a Toshiba Projector

    Hi I wonder if you could help me. I have a dual 1.8 G5, 2Gb Ram, running OS 10.4.6, with a Radeon 9800 Pro with 128MB of Vram. It has both VGA and DVI connections. I recently bought a Toshiba TLP-ET1 LCD Projector, which has VGA and Component video c

  • ERROR[WSDL Parser] Attribute 'name' not found at: wsdl:documentation

    Hello, I'm currently having a problem generating the Java source code from a WSDL, because the WSDL2Service ant class bundled with the WLS install (in the /server/lib/webservices.jar library) does not comply with the WSDL XSD. Check http://schemas.xm