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;
/

Similar Messages

  • 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

  • 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

  • After insert & update trigger

    I need to write a trigger that if some columns of the master table have changed, the trigger will first insert the change to a copy table. Later on, if there are more changes to the master of the same row, it will compare the new value to the old value and delete the same row in the copy table and insert the latest change. I have wrote the following trigger. Some how when I run it, it has compilation error. Does anyone have any idea on how should I approach this?
    create or replace trigger TRITON.AFTER_INSERT_UPDATE_ITM001100after insert or update on TRITON.TTIITM001100for each rowdeclarev_reflag char(1);beginv_reflag:='0';if (:new.T$ITEM != :old.T$ITEM or :new.T$DSCA != :old.T$DSCA) then
    delete from ticcrm.ttiitm001100_copy;
    insert /*+append*/ into ticcrm.ttiitm001100_copy(T$ITEM, T$DSCA, T$DSCB, T$DSCC, T$DSCD, T$WGHT, T$SEAK, REFLAG)values(:new.T$ITEM, :new.T$DSCA, :new.T$DSCB, :new.T$DSCC, :new.T$DSCD, :new.T$WGHT, :new.T$SEAK, v_reflag);
    end if;
    end;
    /

    delete from ticcrm.ttiitm001100_copy;
    insert /*+append*/ into ticcrm.ttiitm001100_copy(T$ITEM, T$DSCA, T$DSCB, T$DSCC, T$DSCD, T$WGHT, T$SEAK, REFLAG)values(:new.T$ITEM, :new.T$DSCA, :new.T$DSCB, :new.T$DSCC, :new.T$DSCD, :new.T$WGHT, :new.T$SEAK, v_reflag);
    This is simple SQL statements, not PL/SQL.
    Use EXECUTE IMMEDIATE for executing it.
    P.S. Please do not forget to make good formatting of your code before posting it.

  • ORA-29532 exception from after insert update trigger

    Trigger code:
    CREATE OR REPLACE TRIGGER SAMS.PERS_ALG_AIU_TRG
         AFTER INSERT OR UPDATE
              ON PERS_ALG
              FOR EACH ROW
    DECLARE
         trans_type          VARCHAR2(1);
         event_id          CONSTANT VARCHAR2(7) := 'A31_ZA1';
         data_src          CONSTANT VARCHAR2(15) := 'SI_A31_ZA1_VW';
         p_row_id          ROWID;
         select_stmt          VARCHAR2(5000);
         XMLString          CLOB;
    BEGIN
         IF INSERTING THEN
              trans_type := 'I';
         ELSE
              trans_type := 'U';
         END IF;
    SELECT ROWID
    INTO p_row_id
    FROM personnel
    WHERE pers_seq = :new.pers_seq;
    select_stmt := 'SELECT * FROM si_a31_ZA1_vw WHERE start_date = MAX(start_date) AND ROW_ID =chartorowid('''||p_row_id||''')';
         -- Produce the XML
    XMLString := si_lib.get_XML(select_stmt);
         -- Insert the transaction
         INSERT INTO si_transaction (transaction_type, event_id, status_id, timestamp, transaction_xml)
              VALUES ( trans_type, event_id, 'CR', SYSDATE, XMLString);
              EXCEPTION
                   WHEN OTHERS THEN
                   RAISE_APPLICATION_ERROR (-20040, sqlerrm);
    END;
    ... is causing ORA-29532 JAVA call terminated by uncaught java exception: java.lang.nullPointerException
    any ideas --- get_XML actually calls dbms_xmlquery.getXML

    When in doubt, break it into pieces and test the pieces. The following is not valid:
    SELECT * FROM si_a31_ZA1_vw WHERE start_date = MAX(start_date)
    Try replacing the above with:
    SELECT * FROM si_a31_ZA1_vw WHERE start_date = (SELECT MAX(start_date) FROM si_a31_ZA1_vw)

  • Php Insert, Update & Delete error "invalid array length" CS5.5

    Getting this error on both the wizard and the non-wizard options.
    I have done all the requested "fixes" including:
    deleting cache file
    deleting .dws file
    move "configuration" file and the regedit correction
    unistalling and reinstalling
    There are no extensions loaded.
    I'm stumped.  Lost my equipment in Hurricane Sandy and re-installed on new system running Win 7.
    Any help would be apprecaited.

    Solution is silly - i upgraded Zend Framework to 1.9.3 patch 1 version.
    In change log we can see:
    * PHP 5.3 compatibility, including support for new features in the
      mysqli extension. All components are fully tested on both PHP 5.2.x
      and PHP 5.3.0.
    Available since 23 sep - so just in time.
    hsz

  • Inserting/updating data in control block based on view

    Hi!
    I`ve created a block based on a view to display data.
    I want this block to be insertable and updateable, that is I will use a on-insert/update trigger to call an insert/update procedure located in the database.
    When trying to change/insert a value in the block, the error message "Error: Can not insert into or update data in a view" pops up. I`ve tried to get rid of this error, without success.
    How can I make a data block based on a view insertable and updateable?
    My guess is that this have something to do with locking the records(there is no rowid in the view)... but I'm not sure.
    Pls advise!!

    Morten
    As well as on-update, on-insert, on-delete triggers you also need an on-lock,
    (even though it might just contain null;) otherwise the form will try to lock the view and fail.
    Actually your terminology is wrong, the block being based on a table or view is not a control block. A control block is not based on anything and has no default functionality for communicating with the database. If it was a control block, the on- triggers would not fire.

  • Insert/Update Record - Server Behavior

    Help Please!
    I have several pages with forms that insert records, but I
    over the weekend when I went to open them from the web to
    insert/update records errors appeared. They were working fine
    before. Using PHP, MYSQL and Dreamweaver CS3
    I have tried everything I know to do. I have recreated the
    page, same problem as well as delete behaviors and reapply them.
    Once the server behavior is added it no longer says Insert
    Record in the Application window instead it says "Dynamic
    Attribute" Further, when I click it to make any changes etc,
    instead of the screen for Insert or Update record coming up it is a
    "Dynamic Text box" regarding POST or GET or URL stuff.
    Edited to add: And once posted, the page only shows an error
    and references this line
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    Error Message
    Parse error: syntax error, unexpected '<' on line 40
    What can I do?

    You don't say which server-side language you're using, but the way that I would troubleshoot this in PHP is to use echo to display the value of $_SESSION['MM_Username'] at the bottom of the admin page. This is the session variable Dreamweaver uses to control access to a page with username and password. If the value is displayed, it means sessions are working, and the variable hasn't been destroyed.
    If that works, move onto the next page, and use echo to display the value of $_SESSION['MM_Username'] as soon as the session has been started. To prevent being redirected to the fail page, temporarily comment out the following line:
    header("Location: ". $MM_restrictGoTo);
    Basically, you need to check what's happening to the session variable that controls access to the pages.

  • How can you create a simple insert or update trigger

    I am trying to create a simple insert or update trigger to timestamp an xml document when I load it into my XML DB repository but I always get an error trying to compile the trigger.
    "ORA-25003: cannot change NEW values for this column type in trigger"
    Here is my PL/SQL:
    CREATE OR REPLACE TRIGGER "PLCSYSADM"."PLCSYSLOG_TIMESTAMP"
    BEFORE
    INSERT
    OR UPDATE ON "PLCSYSADM"."PLCSYSLOG"
    FOR EACH ROW BEGIN
    :new.sys_nc_rowinfo$ := xmltype('<datestamp>' || SYSDATE || '</datestamp>');
    END;
    Does anyone have an example that works ?
    Thanks in advance
    Niels Montanana

    http://developer.apple.com/referencelibrary/HardwareDrivers/idxUSB-date.html

  • Insert, update and delete trigger over multiple Database Links

    Hello guys,
    first of all I'll explain my environment.
    I've got a Master DB and n Slave Databases. Insert, update and delete is only possible on the master DB (in my opinion this was the best way to avoid Data-inconsistencies due to locking problems) and should be passed to slave databases with a trigger. All Slave Databases are attached with DBLinks. And, additional to this things, I'd like to create a job that merges the Master DB into all Slave DB's every x minutes to restore consistency if any Error (eg Network crash) occurs.
    What I want to do now, is to iterate over all DB-Links in my trigger, and issue the insert/update/delete for all attached databases.
    This is possible with the command "execute immediate", but requires me to create textual strings with textually coded field values for the above mentioned commands.
    What I would like to know now, is, if there are any better ways to provide these functions. Important to me is, that all DB-Links are read dynamically from a table and that I don't have to do unnecessary string generations, and maybe affect the performance.
    I'm thankful for every Idea.
    Thank you in advance,
    best regards
    Christoph

    Well, I've been using mysql for a long time, yes, but I thought that this approach would be the best for my requirements.
    Materialized View's don't work for me, because I need real-time updates of the Slaves.
    So, sorry for asking that general, but what would be the best technology for the following problem:
    I've got n globally spread Systems. Each of it can update records in the Database. The easies way would be to provide one central DB, but that doesn't work for me, because when the WAN Connection fails, the System isn't available any longer. So I need to provide core information locally at every System (connected via LAN).
    Very important to me is, that Data remain consistent. That means, that it must not be that 2 systems update the same record on 2 different databases at the same time.
    I hope you understand what I'd need.
    Thank you very much for all your replies.
    best regards
    Christoph
    PS: I forgot to mention that the Databases won't be very large, just about 20k records, and about 10 queriees per second during peak times and there's just the need to sync 1 Table.
    Edited by: 907142 on 10.01.2012 23:14

  • 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

  • AFTER INSERT OR UPDATE TRIGGER

    All of my tables have a dateTime field which is used to track when a record was inserted/updated. I would like a trigger on each table that updates the dateTime field with the current date and time after each insert or update. I keep getting a mutating error and I can't quit wrap my brain around how to fix it. Could anyone provide a example.
    I know I am getting the error because I am trying to update the row that is currently being inserted or updated - what is the best way to handle this?
    Thanks

    Hi,
    A trigger before insert or update is better for your case :
    For example :
    SQL> desc tab_param
    DELAI_RETENTION_FLUX NOT NULL NUMBER(5)
    DATE_DEBUT_ALARME NOT NULL DATE
    DATE_DEBUT_HITSTORIQUE NOT NULL DATE
    NB_FLUX_TOTAL NOT NULL NUMBER(5)
    NB_FLUX_PAGE NOT NULL NUMBER(5)
    DATE_COL DATE
    CREATE OR REPLACE TRIGGER TEST_TRG BEFORE INSERT OR
    UPDATE OF DATE_DEBUT_ALARME, DATE_DEBUT_HITSTORIQUE,
    DELAI_RETENTION_FLUX, NB_FLUX_PAGE, NB_FLUX_TOTAL
    ON TAB_PARAM REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    begin
    :new.date_col:=sysdate;
    end;
    Nicolas.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error meesage on UI sCannot insert/update Array without context information

    Hi All,
    As soon as page runs , i m getting the below error on server logs and also getting the same error once page page loads , user click on SellectmnayListBOx components on screen .
    Appriciate if any inputs on this . using ADF6 .
    <ApplicationModuleImpl> <doPoolMessage>
    oracle.jbo.AfterRollbackException: JBO-26102: An error occurred after rollback was performed.
         at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:2595)
         at oracle.jbo.server.ApplicationModuleImpl.resetState(ApplicationModuleImpl.java:4840)
         at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:336)
         at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:9084)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4607)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.resetApplicationModule(ApplicationPoolImpl.java:2026)
         at oracle.jbo.common.ampool.ApplicationPoolImpl.removeSessionCookie(ApplicationPoolImpl.java:879)
         at oracle.jbo.common.ampool.SessionCookieImpl.removeFromPool(SessionCookieImpl.java:711)
         at oracle.jbo.common.ampool.SessionCookieImpl.destroy(SessionCookieImpl.java:650)
         at oracle.jbo.common.ampool.SessionCookieImpl.timeout(SessionCookieImpl.java:697)
         at oracle.adf.model.bc4j.DCJboDataControl.releaseImmediateAMUnmanaged(DCJboDataControl.java:2525)
         at oracle.adf.model.bc4j.DCJboDataControl.releaseApplicationModule(DCJboDataControl.java:2429)
         at oracle.adf.model.bc4j.DCJboDataControl.release(DCJboDataControl.java:903)
         at oracle.adf.model.dcframe.DataControlFrameImpl.release(DataControlFrameImpl.java:364)
         at oracle.adf.model.BindingContext.resetState(BindingContext.java:637)
         at oracle.adf.model.BindingContext.release(BindingContext.java:609)
         at oracle.adf.model.servlet.HttpBindingContext.valueUnbound(HttpBindingContext.java:77)
         at weblogic.servlet.internal.session.SessionData.removeAttribute(SessionData.java:720)
         at weblogic.servlet.internal.session.SessionData.removeAttribute(SessionData.java:702)
         at weblogic.servlet.internal.session.SessionData.remove(SessionData.java:976)
         at weblogic.servlet.internal.session.MemorySessionContext.invalidateSession(MemorySessionContext.java:69)
         at weblogic.servlet.internal.session.SessionContext.invalidateSession(SessionContext.java:475)
         at weblogic.servlet.internal.session.MemorySessionContext$SessionCleanupAction.run(MemorySessionContext.java:114)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.session.MemorySessionContext.destroy(MemorySessionContext.java:90)
         at weblogic.servlet.internal.WebAppServletContext.destroy(WebAppServletContext.java:3220)
         at weblogic.servlet.internal.ServletContextManager.destroyContext(ServletContextManager.java:247)
         at weblogic.servlet.internal.HttpServer.unloadWebApp(HttpServer.java:461)
         at weblogic.servlet.internal.WebAppModule.destroyContexts(WebAppModule.java:1535)
         at weblogic.servlet.internal.WebAppModule.deactivate(WebAppModule.java:507)
         at weblogic.application.internal.flow.ModuleStateDriver$2.previous(ModuleStateDriver.java:387)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
         at weblogic.application.internal.flow.ModuleStateDriver.deactivate(ModuleStateDriver.java:141)
         at weblogic.application.internal.flow.ScopedModuleDriver.deactivate(ScopedModuleDriver.java:206)
         at weblogic.application.internal.flow.ModuleListenerInvoker.deactivate(ModuleListenerInvoker.java:261)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$2.previous(DeploymentCallbackFlow.java:547)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.deactivate(DeploymentCallbackFlow.java:192)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.deactivate(DeploymentCallbackFlow.java:184)
         at weblogic.application.internal.BaseDeployment$2.previous(BaseDeployment.java:642)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
         at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
         at weblogic.application.internal.BaseDeployment.deactivate(BaseDeployment.java:227)
         at weblogic.application.internal.EarDeployment.deactivate(EarDeployment.java:58)
         at weblogic.application.internal.DeploymentStateChecker.deactivate(DeploymentStateChecker.java:198)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.deactivate(AppContainerInvoker.java:98)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.silentDeactivate(AbstractOperation.java:679)
         at weblogic.deploy.internal.targetserver.operations.RedeployOperation.unprepareDeployment(RedeployOperation.java:197)
         at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare(RedeployOperation.java:120)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: oracle.jbo.JboException: Cannot insert/update Array without context information     at oracle.jbo.domain.Array.prepareForDML(Array.java:802)
         at oracle.jbo.server.ViewRowSetImpl.prepareLobObjectForBind(ViewRowSetImpl.java:8301)
         at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:5074)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1169)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:1397)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:1303)
         at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:1288)
         at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:7107)
         at com.tuitravelad.modelbase.bc.base.vo.TuiTravelADViewObject.afterRollback(TuiTravelADViewObject.java:168)
         at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:2570)
         ... 62 more
    ## Detail 0 ##
    oracle.jbo.JboException: Cannot insert/update Array without context information
         at oracle.jbo.domain.Array.prepareForDML(Array.java:802)
         at oracle.jbo.server.ViewRowSetImpl.prepareLobObjectForBind(ViewRowSetImpl.java:8301)
         at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:5074)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1169)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:1397)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:1303)
    Thanks

    Hi,
    this
    +"As soon as page runs , i m getting the below error on server logs and also getting the same error once page page loads , user click on SellectmnayListBOx components on screen ."+
    cannot be the full story you tell. The exception is thrown in the context of a prepareForDML, which is called on entities for the Create / Update and Delete use case. I also see a failed rollback. So there must be something you do before this happens during a page refresh
    Frank

Maybe you are looking for

  • Windows repair installation Pavilions a6720y Windows Vista 64 bit

    Can you provide a Windows Repair Installation Disc? I recently had a serious PC problem. I knew that I would have to hand my PC over to someone and selected a Local Technical Specialists (Geek Squad) who diagnosed it as a crashed main HD, installed a

  • Error: Path to object does not exist at Request

    Hi experts, i have a scenario asynchronous/syncrhonous: file to rfc and get back response rfc to other file. I have 3 communication channel: 1 sender file, 1 receiver file, 1 receiver RFC. The communication channel sender file show the follow error:

  • Installing an AIR application from the browser

    I am installing an application using a custom badge. Is there any documentation on air.swf? After air.installApplication() is called is there anyway to know what happens, i.e. some event to listen to. How can I know when installation is complete or i

  • Active Sync - What attributes to set in UserMap

    I am have written an active sync adapter for MySQL Table. I am not sure what attributes to add in the user map object that is passed in the list of updates. I get the following error: The result of submitting the message - com.waveset.exception.FormV

  • MXF and FCE HD 3.5

    Hello! An important question (for me!): do you know if Final Cut Express HD 3.5 imports MXF files? I have an external hard disk but i can't import these files... Thank you! Cribe