Help discovering what's wrong w/ my before update trigger

Let me prefix this w/ the fact that I'm an idiot, so be kind.
I have one trigger that is not working (seemingly), and I am about googled out so I thought I'd ask and see if anyone couldn't provide thoughts, insults, suggestions or what have you.
Database being used is 10g XE and updates are being done transactionally.
I have a table that stores (among other things) the status of a particular type of (app specific) transaction. When that status changes to a particular value, I have a trigger that updates another table with the date that this status change took place.
<pre>Table: XTransaction
id (pk)
statusid (int)
...</pre>
and here is what my trigger looks like:
<pre>create or replace trigger x_transaction_update before update on xtransaction
for each row
declare
begin
if( :old.statusid = 1) then -- this is here because I got an error when I tried to use a when clause above
begin
-- I log before the update w/ some other info to tell whether I've been to this spot or not
update sometable set when_it_happened = sysdate where xtransid = :old.id;
-- I log after the update too
exception
when others then
-- I log sqlerrm
end;
end;
end if;
end;</pre>
here's what I've been able to gather through testing & viewing logs from the trigger:
1. there's no exception being logged,
2. the pre/post update logs with all the correct data (proving that the trigger is fired),
3. when I update xtransaction from visual studio (through the oracle addin which lets you run queries against the database), the status is changed, the trigger is fired, and the other table is updated.
4. when the application that normally updates the xtransaction table runs, xtransaction is updated, the trigger is fired, and sometable is not updated.
so I have absolutely no clue where to go with this one. Usually I could fire up sql server's query analyser and watch what's coming through, and I've tried to use toad's commercial tool to do this, but to no avail. I've tried changing it to an after update, but had the same results. I wrote this some months ago, and it was working then, but not now.

MadHatter wrote:
@Centinul
the only difference between what I posted and the actual trigger are table / column names, and a sproc I wrote for the logging in place of the comments I have:
log_msg('update sometable set arrival = sysdate where transid = ' || :old.id);I know this doesn't answer the question you have now, you should seriously consider removing the WHEN OTHERS clause altogether OR ensure that there is a RAISE or RAISE_APPLICATION_ERROR there.
This trigger isn't syntactically correct either:
create or replace trigger x_transaction_update before update on xtransaction
for each row
declare
begin
    if( :old.statusid = 1) then -- this is here because I got an error when I tried to use a when clause above
        begin
            -- I log before the update w/ some other info to tell whether I've been to this spot or not
            update sometable set when_it_happened = sysdate where xtransid = :old.id;
            -- I log after the update too
        exception
            when others then
                -- I log sqlerrm
            end;
        end; /* Extra END here.... */
    end if;
end;Edited by: Centinul on Oct 30, 2009 1:23 PM

Similar Messages

  • 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

  • BEFORE UPDATE Trigger

    Hi,
    I'm looking for a solution to find out which columns are set in the update-statement inside a before update trigger. Can someone give me a hint?!
    What I want to do:
    I want to ensure that an update-statement for a special table always include attribute "XXX". To declare this attribute as "not null" is useless, because it is set correctly at insert. To compare the new value against the old value in a before update trigger isn't possible because the new value can be the same as the old value.
    I'm using Oracle 8i.

    There is no need to use two triggers and a temporary table where a simple insert from the before trigger will do the job.
    You can just insert the :old.column values straigth into a history table within the before update trigger though I would prefer to use an after update trigger. Nevertheless, both the insert into history and the update will be part of one transaction so the two action will commit or rollback together:
    UT1 > create or replace trigger marktest_bu
    2 before update on marktest
    3 for each row
    4 begin
    5 insert into marktest_hist
    6 values (:old.fld1, :old.fld2, :old.fld3, :old.fld4);
    7 end;
    8 /
    Trigger created.
    UT1 > select * from marktest_hist;
    no rows selected
    UT1 > update marktest set fld1 = 'trigtest2'
    2 where fld1 = 'trigtest';
    1 row updated.
    UT1 > select * from marktest_hist;
    FLD1 FLD2 FLD3 FLD4
    trigtest 9 28-MAY-04 trigtest
    IMHO -- Mark D Powell --

  • Slow update on 11g in conjuction with before update trigger

    Hello,
    I have strange problem - when on table exists before update trigger(in its body is nothing important, maybe problem is on other triggers aswell), then repeating update on this table is slower and slower on 11g, on 10g it is ok. Problem is on windows and linux platform aswell.
    I created some scripts to simulate this behavior, in table is 60 000 row. In one loop I update all 60 000 rows from table and measure time.
    Can someone tell me where problem is and if it is possible to manage it with some settings or anyway ? In our application it is big problem, similar operation takes days ......
    thanks tomas
    times for 10g:
    Trigger disabled
    Loop 1 - 6,13 secs
    Loop 2 - 2,92 secs
    Loop 3 - 3,19 secs
    Loop 4 - 2,95 secs
    Loop 5 - 3,39 secs
    Trigger enabled
    Loop 1 - 4,83 secs
    Loop 2 - 3,78 secs
    Loop 3 - 4,75 secs
    Loop 4 - 3,91 secs
    Loop 5 - 3,81 secs
    times for 11g:
    Trigger disabled
    Loop 1 - 2,27 secs
    Loop 2 - 2,4 secs
    Loop 3 - 2,3 secs
    Loop 4 - 2,42 secs
    Loop 5 - 2,36 secs
    Trigger enabled
    Loop 1 - 8,01 secs
    Loop 2 - 17,22 secs
    Loop 3 - 29,21 secs
    Loop 4 - 58,43 secs
    Loop 5 - 115,59 secs
    script for create test table
    CREATE TABLE SD3Test
       (MPID INTEGER NOT NULL ENABLE,
    ROWCOUNT NUMBER(10,0),
    CLOSEDROWCOUNT NUMBER(10,0),
    AMOUNT NUMBER(18,2) DEFAULT 0 NOT NULL ENABLE,
    LOCALAMOUNT NUMBER(18,2) DEFAULT 0 NOT NULL ENABLE,
    CLOSED CHAR(1 BYTE) DEFAULT 'N' NOT NULL ENABLE);
    ALTER TABLE SD3Test ADD CONSTRAINT SD3TestPK PRIMARY KEY (MPID);
    --fill test data
    DECLARE mCnt INTEGER;
    BEGIN
    mCnt := 0;
    FOR mCnt IN 1..60000 loop
      INSERT INTO SD3Test (MPID, Amount, LocalAmount, RowCount, ClosedRowCount)
      VALUES(mCnt, 0, 0, 0, 0);
    END loop;
    END;
    --create trigger
    CREATE OR REPLACE TRIGGER SD3TestAU
      BEFORE UPDATE ON SD3Test FOR EACH ROW
    DECLARE
    mInt INTEGER;
    BEGIN
      /*original code of our trigger, but performance problem is
    not depend on it, just depend on existence of this trigger
    IF ((:new.RowCount=:new.ClosedRowCount) and (:new.RowCount>0)) THEN
      :new.Closed:='A';
    ELSE
      :new.Closed:='N';
    end if;
    mInt := 1;
    END;
    / script for run test
    --test for updates with trigger disabled and enabled
    set serveroutput on;
    DECLARE
      mCnt INTEGER;
      mLoop INTEGER;
      mDisEna INTEGER;
      mStart NUMBER;
      mStop NUMBER;
    BEGIN
    --2 loops - first with disabled trigger, second with enabled trigger
    FOR mDisEna IN 1..2 loop
      IF mDisEna = 1 THEN
       execute immediate 'ALTER TRIGGER SD3TestAU disable';
       dbms_output.put_line('Trigger disabled');
      ELSE
       execute immediate 'ALTER TRIGGER SD3TestAU enable';
       dbms_output.put_line('Trigger enabled');
      END IF;
      -- 3 inner loops for measure time
      FOR mLoop IN 1..3 loop
        --update on all records in table
       mStart := dbms_utility.get_time;
       FOR mCnt IN 1..60000 loop
        UPDATE SD3Test
         SET
        ROWCOUNT = ROWCOUNT+1,
        CLOSEDROWCOUNT = CLOSEDROWCOUNT+1,
        AMOUNT = AMOUNT + mCnt,
        LOCALAMOUNT = LOCALAMOUNT + mCnt
        WHERE
         MPID = mCnt;
       END loop;
       mStop := dbms_utility.get_time;
       dbms_output.put_line('Loop ' || mLoop || ' - ' || round((mStop - mStart)/100,2) || ' secs');
      END loop;
    END loop;
    END;
    /

    Hello,
    Your case has been reported as a bug #7173924 (TRIGGER IS MUCH SLOWER IN 11G) few days ago.
    Still on analyze.
    Nicolas.

  • I can't play a bought video in iTunes, and VLC only plays it but no screen. And I have to athourize all the time but it does not help. What's wrong?

    Hi all.
    Just bought my first video from iTunes Store and should watch it with my son. I had to authorize, this and that for some time, but finally I got the video in my iTunes, but it was just a black screen. Nothing playing and no sound (of course). So I tried VLC and it was at least runing there, but no screen and no sound. Quick time said I had to authorize my iTunes acount first (which I had done several times before) and did it again with just the same result, nothing happening. What's wrong? I'm no geek so please help me out with this, I thought it should be easy piecy with a iMac and iTunes, well, hope it was a one in a million problem.
    Thanks

    Could be a corrupt Download.
    If you live in a Region that allows re-downloading Music...
    Delete the Song(s) and re-download...
    See Here  >  Download Past Purchases  >  http://support.apple.com/kb/HT2519
    If not... Contact iTunes Customer Service  >  Apple  Support  iTunes Store  Contact Us

  • HELP!What's wrong with my GZIP program?

    Here's part of the source code:
    static void Compress(String strfilename)     
         int iTemp;
         try
              BufferedReader brIn=new BufferedReader(new FileReader(strfilename));
              BufferedOutputStream bosOut=new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(strfilename+".gz")));
              while(true)
                   iTemp=brIn.read();
                   if(iTemp==-1) break;
                   bosOut.write(iTemp);                         }
              brIn.close();
              bosOut.close();
         catch(Exception e)
              System.out.println("Error: "+e);
    If I use it to compress a small file(20k),the compression is successful,and I can also see it using WINRAR;but once I decompress
    this GZIP file,all the English words are correct,while other unicodes
    such as Chinese become unrecognizable;
    If I use it to compress a "large" file(3M) such as abc.chm,the size of the compressed file is about 2M(INCREDIBLE! WINRAR can only decrease
    the size of this file by 30k);But..the size of decompressed file is
    still about 2M,and windows cannot read it (Invalid page error).
    I wonder what's wrong with my program? Even if I use "javac -encoding
    gb2312 ..." to compile my program,the result is also the same.
    HOW SHOULD I DO??

    Hi, jchc,
    Let me help you a little bit, here. hwalkup is correct that for data compression you should use input and output stream instead of readers and writers. I don't think that mixing a reader with an output stream would work anyway as streams read and write bytes (8-bit data), while readers and writers read and write characters (16-bit data). hwalkup is also correct to suggest that you should use a buffer (a byte[]) to improve the performance of your streaming processes.
    Here is code for methods to compress and decompress one file into another. Note: the decompress() method will throw an IOException if the file to decompress (inFile) is not actually compressed in the first place.
        public static void compress(File inFile, File outFile)
                throws FileNotFoundException, IOException {
            InputStream in = null;
            OutputStream out = null;
            try {
                in = new BufferedInputStream(new FileInputStream(inFile));
                GZIPOutputStream gzipOut = new GZIPOutputStream(
                                           new FileOutputStream(outFile));
                out = new BufferedOutputStream(gzipOut);
                byte[] buffer = new byte[512];
                for (int i = 0; (i = in.read(buffer)) > -1; ) {
                    out.write(buffer, 0, i);
                out.flush();
                gzipOut.finish(); // absolutely necessary
            } finally {
                // always close your output streams before your input streams
                if (out != null) {
                    try {
                        out.close();
                    } catch (IOException e) {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
        public static void decompress(File inFile, File outFile)
                throws FileNotFoundException, IOException {
            InputStream in = null;
            OutputStream out = null;
            try {
                GZIPInputStream gzipIn = new GZIPInputStream(
                                         new FileInputStream(inFile));
                in = new BufferedInputStream(gzipIn);
                out = new BufferedOutputStream(new FileOutputStream(outFile));
                byte[] buffer = new byte[512];
                for (int i = 0; (i = in.read(buffer)) > -1; ) {
                    out.write(buffer, 0, i);
                out.flush();
            } finally {
                // always close your output streams before your input streams
                if (out != null) {
                    try {
                        out.close();
                    } catch (IOException e) {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
        }Shaun

  • TS1717 Installed the iTunes 10 update on my computer (Windows 7).  iTunes will no longer launch and I get no error msg. Tried uninstalling and reinstalling entire app but no help.  Tried setting up a new user, no help.  What's wrong??

    Installed the iTunes 10 update on my computer (Windows 7).  iTunes will no longer launch and I get no error msg. Tried uninstalling and reinstalling entire app but no help. What's the fix??

    Hi sahgin,
    The issue eventually resolved itself, I still don't really know why. I kept up with Windows update, and attempted downloading iTunes again from the Apple website, and it just... worked. It now works fine. I don't know why it took approximately 4 months to work, though.
    I'm sorry I don't have any more helpful information. Posting here was my last resort, and clearly Apple never bothered to reply.

  • Help. What's wrong with ows302 ?? :-

    error opening UDP:westteam:2649
    OWS-08820: Unable to start WRB process
    `/u01/app/oracle/product/8.0.5/ows/3.0/bin/mnaddrsrv'.
    null

    Qi wrote:
    Hello,
    I was trying to use the following stop script to stop the wls8.1 server:
    echo "Stopping WebLogic for Domain"
    rm -f $PIDFILE
    java weblogic.Admin -url localhost:7003 FORCESHUTDOWN
    But got the following error:
    $ ./stop.sh
    Stopping WebLogic for Domain
    Cannot shutdown a server when using a BootIdentify file AND running in Production
    mode
    What's wrong with it? How should I modify my stop script and have it work?
    Thanks a lot
    Qi
    Qi,
    You can try passing in -username and -password arguments. If you don't
    like the idea of storing username and password in plain text in a
    script, as well you shouldn't ;), you can create a user config file.

  • Help! What's wrong with my "stop" script?

    Hello,
    I was trying to use the following stop script to stop the wls8.1 server:
    echo "Stopping WebLogic for Domain"
    rm -f $PIDFILE
    java weblogic.Admin -url localhost:7003 FORCESHUTDOWN
    But got the following error:
    $ ./stop.sh
    Stopping WebLogic for Domain
    Cannot shutdown a server when using a BootIdentify file AND running in Production
    mode
    What's wrong with it? How should I modify my stop script and have it work?
    Thanks a lot
    Qi

    Qi wrote:
    Hello,
    I was trying to use the following stop script to stop the wls8.1 server:
    echo "Stopping WebLogic for Domain"
    rm -f $PIDFILE
    java weblogic.Admin -url localhost:7003 FORCESHUTDOWN
    But got the following error:
    $ ./stop.sh
    Stopping WebLogic for Domain
    Cannot shutdown a server when using a BootIdentify file AND running in Production
    mode
    What's wrong with it? How should I modify my stop script and have it work?
    Thanks a lot
    Qi
    Qi,
    You can try passing in -username and -password arguments. If you don't
    like the idea of storing username and password in plain text in a
    script, as well you shouldn't ;), you can create a user config file.

  • I'm unable to "reply" to my emails and also am unable to "compose" an email. This only just started happening within a week ago. Help! What's wrong?

    Just under a week ago, I have not been able to "reply" or "compose" an email with Firefox. What went wrong?
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7

    Have you tried a PRAM reset?
    http://support.apple.com/kb/HT1379
    Ciao.

  • Before Update Trigger compilation problem

    Hello experts! I have a compilation problem for a trigger I am trying to create.
    As a matter of fact it should update INT_INITIAL with the old value of INT_LOCK.
    The compilation fails and the debugger raises an ORA 01747 error (invalid declaration for user table, user column etc.)
    Do you have an idea what is wrong with my code?
    create or replace
    TRIGGER TRIGGER_INT_INITIAL
    BEFORE UPDATE ON  TBL_MATRIX_INTERMEDIATE_RESULT
    FOR EACH ROW
    Begin
      IF NVL(:new.INT_INITIAL, 0) != :old.INT_LOCK THEN
           UPDATE TBL_MATRIX_INTERMEDIATE_RESULT set
          :NEW.INT_INITIAL = :old.INT_LOCK;
      END IF;
    END;Regards,
    Seb

    Hi Seb,
    You don't need to use UPDATE stmt here as you are updating the same table on which your trigger is fired. So it may cause mutating table error too.
    when you use :new.colname it will immediately take care of the new value to be inserted in the respective column.
    So no need to write Update stmt.
    Hence remove,
    UPDATE TBL_MATRIX_INTERMEDIATE_RESULT set And use := is an assignment operator whereas = is to equate..
    :=Twinkle

  • Before Update Trigger has mutating problem

    I'm getting a mutating problem with this updating trigger. I'm not sure how to deal with it. Here is my code:
    CREATE OR REPLACE TRIGGER WTL_SMP_TRG2
    BEFORE UPDATE ON WTL_SAMPLES
    FOR EACH ROW
    DECLARE
         sampleCount NUMBER(1) := 0;
         dupLabSampleID NUMBER(8) := 0;
    BEGIN
         SELECT COUNT(sample_ID)
         INTO sampleCount
         FROM wtl_samples
    WHERE jb_job_id = :new.jb_job_id
    AND lab_no = :new.lab_no
         AND sample_ID != :old.sample_ID;
         IF sampleCount > 0 THEN
         SELECT sample_ID
         INTO dupLabSampleID
         FROM wtl_samples
         WHERE jb_job_id = :new.jb_job_id
         AND lab_no = :new.lab_no
              AND sample_ID != :old.sample_ID;
    RAISE_APPLICATION_ERROR(-20501, 'Update failed, Lab Number ' || :new.lab_no || ' is used by SampleID: ' || dupLabSampleID);
    END IF;
    --EXCEPTION
    --     WHEN OTHERS THEN
    -- RAISE_APPLICATION_ERROR(-20901, 'Error in WTL_SMP_TRG2.');
    END WTL_SMP_TRG2;
    any help appreciated
    adam

    I guess I couldve done that, but was using design editor and didn't know how to put a unique constraint in. Is the problem only because I'm referencing the :old.sample_ID, or the :new values as well? If it's just the :old value I could write a before update statement trigger to place the sample_id into a package varaible and then call that variable up in the row level trigger.... i've tried this, but don't know how to pull the sample_id value i need in the before statement trigger... i'll supply the code i've done so far...
    CREATE OR REPLACE TRIGGER WTL_SMP_TRG2_INIT
    BEFORE UPDATE ON WTL_SAMPLES
    DECLARE
    BEGIN
         wtl_trg_custom_pkg.oldSampleID := sample_id; /* Doesn't know sample_id...? */
    END WTL_SMP_TRG2_INIT;

  • After/before update trigger

    Hi All
    Does any onoe know
    what 's the difference between after update/insert trigger and before update/insert trigger
    on database tables.

    Hi
    The basic diffrence is
    Before Update triggers before the table is updated and
    After update triggers after the table is updated but
    before the implicit commit fires.
    therefore when you raise the application error a
    implicit Rollback happens and the record is not commited.
    Regards
    Shajesh Nair
    Deloitte.
    [email protected]

  • 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

  • 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

Maybe you are looking for

  • Why does the new firefox sync not sync my bookmarks on my Iphone? The history and tabs show up, but bookmarks do not.

    Ever since I updated to the new Firefox sync my bookmarks have stopped showing up on my iphone Sync for Firefox. I even downloaded the Apollo browser, but bookmarks still are not showing. Can someone help?

  • Problem in forwarding to a JSP file

    Here is my code. I'm not able to forward to another jsp when I click on the modify button. If I display anything using alert inside the modify function, it is displaying. But when I include the forward statement, the entire screen becomes blank. What

  • Adobe Help not loading

    When I go to the Photoshop help menu, I get a message that the Help center is not loading. Checking my applications menu, I see that the Adobe Help Viewer has a question mark by it. A message said I may have to reinstall the Help Center. Do I have to

  • Time field in Smartforms

    How is the time field formatted in smartform. Format that has to appeared is hh:mm. But i'm getting hh:mm:ss. How to quote this?

  • Configure about the DATA GUARD APPLICATION on ORACLE 9i platform

    I have worked on Oracle 9i (9.2.0.1) platform. I have installed Oracle 9i server edition in my machine, and created one database name ORCL. I want to configure DATA GUARD APPLICATION in my machine... is it possible? if it is then how can I do this...