Changing the trigger error

Hi all

I am trying to use the trigger, but I get the mutation of error:

This is my original table:
BUS_CYC_D                 CYC_STRT_OF_DAY_DT        BUS_CYC_STAT_C CYC_END_OF_DAY_DT         CCUR_N                 CRE_T                     CRE_USR_ID UPD_T                     UPD_USR_ID 
------------------------- ------------------------- -------------- ------------------------- ---------------------- ------------------------- ---------- ------------------------- ---------- 
08-DEC-08                 08-DEC-08                 ACTV         09-DEC-08                 1                      08-DEC-08 12.00.00.000000000 AM TAAC       08-DEC-08 12.00.00.000000000 AM seeding 
I wrote a trigger to avoid insertion of a date 'ACTIVE' user. My trigger is defined as:
CREATE OR REPLACE TRIGGER trg_bus_cyc_valid_br
BEFORE INSERT
ON t_bus_cyc
FOR EACH ROW

DECLARE
 

pctx                          plog.log_ctx := plog.init('Trigger.trg_bus_cyc_valid_br');
v_unit_context                VARCHAR2(1500);
v_count                       NUMBER(10,0) := 0;
raiseexcp                           EXCEPTION;

BEGIN

    
--    v_unit_context := 'Fetch if t_bus_cyc table already have active record'; 
      
     SELECT COUNT(1) 
     INTO v_count
    FROM t_bus_cyc tbc
    WHERE tbc.bus_cyc_stat_c ='ACTV';
     
--     v_unit_context := 'Fetch if t_bus_cyc table already have active record'; 
     
     IF :NEW.bus_cyc_stat_c = 'ACTV' AND v_count = 1
     THEN
          RAISE raiseexcp;
    END IF;
     
  --  plog.setendsection(pctx,'SECTION_1');

EXCEPTION
     WHEN raiseexcp
     THEN
          RAISE_APPLICATION_ERROR (-20000,'DUPLICATE ACTIVE DATES');    

END  trg_bus_cyc_valid_br;
But when I try to use something like, I get the error transfer:

     INSERT INTO t_bus_cyc
          (bus_cyc_d,
           bus_cyc_stat_c,
           cyc_strt_of_day_dt,
           cyc_end_of_day_dt,
           cre_usr_id,
           upd_usr_id)
     SELECT max(bus_cyc_d) +1  ,
            'INACTVE',
            max(bus_cyc_d) -1,
            max(bus_cyc_d) -1,
            'A',
            'A'
     FROM t_bus_cyc where bus_cyc_d = '08-DEC-08'  
Please something to avoid the mistake of the mutation.

Hello

I think I misread your original message, and I changed it when you answered. My apologies.

It looks like all this you want to do is raise an error if someone tries to add a second line "ACTV.
You better not to use a trigger while: more it can be done with a unique index, LIKE THIS:

CREATE UNIQUE INDEX     t_bus_cyc_actv
ON t_bus_cyc ( CASE
               WHEN  bus_cyc_stat_c ='ACTV'
               THEN  1
            END
          );

In general, when you have the choice of doing something with a trigger or some other way (such as a constraint or an index), then the other way is almost always better. Etbin statement "triggers are evil" is perhaps a little exaggerated, but it is something short and catchy to remember.

The error you are getting now is that a FOR EACH ROW trigger on t_bus_cyc cannot reference t_bus_cyc himself.
The link I posted shows different ways to get around that. As Peter says, none of them are really the best solution for your problem.

Tags: Database

Similar Questions

  • Change the default error messages

    Hello..

    I want to change the default error message in the apex. for example, I want to change the default error message is not Null, then instead of "Field1 must have a certain value" I want to get "Field1 must not be zero.

    Thank you

    Hi "user12974236"

    Take a look at "Translating Messages used internally by Oracle Application Express" - http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/global.htm#CHDJFHBD
    That is the message of APEX. PAGE_ITEM_IS_REQUIRED that is used by the validation not zero standard integrated.

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins

  • Manually change the trigger threshold

    I'm new to LabView and I looked around the forum, trying to find a solution to a problem I have. I wish I could have a trigger that detects a threshold that I can change on the fly. Now my program has an amplitude of setting it off, but I would like to be able to drag a slider and change the threshold I'll. A bonus would be to have the threshold value display on the chart that I use, but it is not necessary.

    http://forums.NI.com/NI/board/message?board.ID=170&message.ID=283779

    The post above is pretty much what I need, but I did not identify most of the controls used, and there is no source file to look at. Is it possible to change the threshold on the fly without having to mess with tables as in the example above? If not, could someone please explain the process to me.


  • Change the Wizard error

    We are on PT 8.53.04 and end/SCM 9.10 Windows/MS-SQL

    Change Wizard is run on the Windows Server, not the client

    Other users can run Assistant change without problem, but I get the below error after I connected, validated configuration and click "apply packages:

    CA_ERROR.jpg

    As I said, it is run on the server and others can use it OK, so this isn't the CA configuration that is the problem. Does anyone have an idea how I can reduce this problem?

    Thank you

    2844096

    Yes, I think that this has something to do with the zip file, you try to use or have permissions to it.  the extractProject is probably trying to remove the project zip file and can't.  I would look at the file updxxxxxx.zip see if your username can read or extract properly.

  • Change the inline error notification in a form.

    Hello

    I try to change the behavior of the online error messages.
    Now, I get added to the label (s) error messages.
    I want the errors only in the notification area AND make a red border around the input fields which the error occurs.

    Through the CCS I can only find a way to change the labels not the input fields.

    Does anyone know a way to do this?

    Thanks in advantage,
    Kees

    Hello

    I found the solution through google.

    http://dbswh.webhop.NET/Apex/f?p=blog:read:0:article:369800346226541

    Kees

  • Change the auxiliary error

    Hi, here is the log when you try to validate the change Wizard. PSEMAgent worked all night. Is there another agent that must be run to 8.50.07 tools? (I never got this message for tools 8.48): -.

    [Wed Apr 21 11:09:51 EST 2010] Start the posting
    writing to: C:\ChangeAssistant\validate\validate_2010_4_21_11_9.log
    (Step 1) Creating a summary of your environment
    PS_HOME: C:\PS\PT8.48\
    Output directory: C:\TEMP\output89\
    Staging directory: C:\TEMP\stage89\
    Path: C:\ChangeAssistant\jre\bin; ; C:\WINDOWS\Sun\Java\bin; C:\Windows\System32; C:\WINDOWS; C:\PS\PT8.48\bin\client\winx86; C:\oracle\product\10.2.0\db_1\bin; C:\Windows\System32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\Program Files\NTRU Cryptosystems\NTRU TCG Software Stack\bin\; C:\Program Files\Wave systems Corp\Gemalto\Access Client\v5\; C:\Program Files\Intel\DMIX; C:\Program Files\Intel\WiFi\bin\; C:\PS\PT8.48\bin\server\WINX86; C:\oracle\tuxedo10gR3_VS2005\bin; C:\oracle\tuxedo10gR3_VS2005\jre\bin\server; C:\oracle\tuxedo10gR3_VS2005\jre\bin
    CLASSPATH: C:\ChangeAssistant\changeassistant.jar; C:\ChangeAssistant\mx4j-JMX.jar; C:\ChangeAssistant\xercesImpl.jar; C:\ChangeAssistant\xml-APIs.jar; C:\ChangeAssistant\xalan_2_7_0.jar; C:\ChangeAssistant\serializer.jar; C:\ChangeAssistant\commons-logging-1.0.1.jar; C:\ChangeAssistant\commons-HttpClient-2.0-RC1.jar; C:\ChangeAssistant\commons-NET-FTP-2.0.jar; C:\ChangeAssistant\commons-codec-1.1.jar; C:\ChangeAssistant\xmldb-API-20021118.jar; C:\ChangeAssistant\xmldb-common.jar; C:\ChangeAssistant\xmldb-XUpdate-20040205.jar; C:\ChangeAssistant\xindice-1.1B5-dev.jar; C:\ChangeAssistant\psemf.jar; C:\ChangeAssistant\psjoa.jar; C:\ChangeAssistant\AbsoluteLayout.jar; C:\ChangeAssistant\log4j-1.2.8.jar; C:\ChangeAssistant\jxl.jar; C:\ChangeAssistant\j2ee.jar
    Current Working Directory: C:\ChangeAssistant
    Fact.
    (Step 2) Validation of your SQL query tools
    Oracle SQL query tool found at c:\oracle\product\10.2.0\db_1\bin\sqlplus.exe
    Fact. 1 found SQL query tool.
    (Step 3) Hub management environment ping
    Ping ascvb01.asc.local
    Fact.
    (Step 4) Connection to the Hub: http://ascvb01.asc.local:9080/PSEMHUB/hub
    Fact.
    * (Step 5) discovered easy Hub
    Failed.   No environments not found in the center of environmental management.
    Note: All agents should be running and sending impulses for applications,.

    Batch, files and Web servers for the environment before change Wizard is started.
    (Step 6) MetaLink ping
    Ping TFTP - updates.oracle.com
    Fact.
    * (Step 7) Validating connection to the site of the opening of the session: https://psft-updates.oracle.com/ice/index.html *.
    No server defined in the configuration settings.  Direct connection to the https://psft-updates.oracle.com/ice/index.html
    Encountered error connect to https://psft-updates.oracle.com/ice/index.html: sun.security.validator.ValidatorException: building way PKIX failed: sun.security.provider.certpath.SunCertPathBuilderException: could not find the path of valid certification for target asked
    Failed.
    (Step 8) Ping gateway update
    Ping TFTP - updates.oracle.com
    Fact.
    (Step 9) Validate the connection to the gateway update: https://psft-updates.oracle.com/PSIGW/HttpListeningConnector
    No server defined in the configuration settings. Direct connection to the https://psft-updates.oracle.com/PSIGW/HttpListeningConnector
    Fact.
    [Wed Apr 21 11:10:06 CEST 2010] Validation of end
    Unsuccessful end (2 steps Failed). Click view log to display additional messages.



    Thanks for the help,
    Vikas

    Published by: VikasB on April 21, 2010 11:24

    Hi - I've corrected the mistake of Step 7 as follows:

    Delete all certificates in Internet Explorer
    Make a backup of the keystore file in c:\Program Files\Peoplesoft\Change Wizard.

    Connected to https://psft-updates.oracle.com/ice/index.html - to obtain 2 certificates
    Recorded 2 certificates in c:\Program Files\Peoplesoft\Change Wizard.
    The two imported as follows:
    jre\bin\keytool - VeriSign importcert-alias - keystore C:\PROGRA~1\PEOPLE~1\CHANGE~1\keystore-fichier VeriSign.cer

    jre\bin\keytool - importcert-alias VeriSignClass3PublicPrimaryCA - keystore C:\PROGRA~1\PEOPLE~1\CHANGE~1\keystore-fichier VeriSignClass3PublicPrimaryCA.cer

    For the second certificate, I have removed the spaces in the name.

    Now it works fine.

  • How can I change the word "error" to "ready" on my connection with my printer so that I can print?

    Printer is HP Photosmart C5100 series, I had only 1 printer who kept showing the error instead of loan so I added 2 additional printers and I have the same problem with all of them.

    Ink is correct and the 3 are to be online.  It was printing fine about 2 weeks ago.

    It has happened, then began to work properly - I don't know why it started working right but I can't print.  It will display 'ready' if I send it to a single Note, but I need to print immediately.

    The printer prints a copy of something if you ask on the menu screen and use which is on the printer itself.

    Have you given it a shot?
    HP Print doctor for help with many printing problems

    http://h10025.www1.HP.com/ewfrf/wc/document?cc=us&LC=en&docName=c02073861&JumpID=ex_r4155/HHO/IPG/ccdoc/trailhead_doc&lang=en

    I hope this helps.

  • Mod_user handling in a table using the trigger

    Hello

    I have a table with two columns value ' test' and the mod_user. Currently, the table has a before Update trigger to update the mod_user as a user of the system
    Now, I need to change the trigger to meet the criteria below

    (1) in an update statement if I manually put the mod_user, then it should be updated such as defined in the update statement.

    For example:
    UPDATE test
    Value = 1,
    mod_user = "xyz".
    WHERE value = 4;

    In the scenario above mod_user should be updated to "xyz" in the table

    (2) if I don't talk to any term set for mod_user, the default windows user should be changed in the table.
    UPDATE test
    Value = 1
    WHERE value = 4;

    In the scenario above mod_user should be updated as a user of windows in the table

    The trigger statement, I used doesn't seem to work.

    CREATE OR REPLACE TRIGGER t_mod_test
    BEFORE the UPDATE OF value WE test
    FOR EACH LINE
    BEGIN
    : new.mod_user: = NVL (SYS_CONTEXT ('USERENV', 'OS_USER'), USER);
    END;

    Any suggestions on how I can do the work of scenario would be very appreciated.

    Thanks in advance
    DAS

    It looks like you want something like

    SQL> create table test(
      2    value number,
      3    mod_user varchar2(100)
      4  );
    
    Table created.
    
    SQL> create or replace trigger t_mod_test
      2    before update on test
      3    for each row
      4  begin
      5    if( updating( 'MOD_USER' ) )
      6    then
      7      null;
      8    else
      9      :new.mod_user := NVL( sys_context('USERENV', 'OS_USER')
     10                           ,user );
     11    end if;
     12  end;
     13  /
    
    Trigger created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace trigger t_mod_test
      2    before update on test
      3    for each row
      4  begin
      5    if( not updating( 'MOD_USER' ) )
      6    then
      7      :new.mod_user := NVL( sys_context('USERENV', 'OS_USER')
      8                           ,user );
      9    end if;
     10* end;
    SQL> /
    
    Trigger created.
    
    SQL> insert into test values( 4, 'xyz' );
    
    1 row created.
    
    SQL> update test
      2     set value = 1
      3        ,mod_user = 'abc'
      4   where value = 4;
    
    1 row updated.
    
    SQL> select * from test;
    
         VALUE MOD_USER
    ---------- ----------
             1 abc
    
    SQL> update test
      2     set value = 2
      3   where value = 1;
    
    1 row updated.
    
    SQL> select * from test;
    
         VALUE
    ----------
    MOD_USER
    ------------------------------------------------------------------------------
    
             2
    JCAVEDDBC64\jcave
    
    SQL>
    

    Justin

  • DropDownList 'change' event trigger

    I have a dilemma with a spark DropDownList I have in my application. I've got feature when the clicks (mouseUp) user anywhere in the main area of the screen, a Menu item appears. Now, the DropDownList control is at the top of the screen, and when clicked, it opens as it should. The problem is that the 'change' event fires when a mouseDown on the selection, so when the user clicks on the button down, the menu disappears and when mouse returns to the top it then triggers the Menu element, so that whenever they click on an item in the DropDownList control, the Menu just appeared immediately after.

    It's extremely frustrating, so I wonder if there is a way to change the trigger for the event changes an instead of a mouseDown mouseUp. Thank you.

    Why not listen to CLICKING instead of MOUSE_UP?  Then this is the thing the mouse

    down, has the same thing on the mouse rises.

  • Change the value to trigger record data for 1 s sampling frequency of 50 KHz

    Hello

    I have a VI with NI9215 and cDAQ-9178 chassis hardware. The function of the VI came out an instruction to RS232 interface and record 1 second of data every time that the set point is changed.

    The procedure is

    (1) modify the policy to the flow regulator

    (2) wait 2 seconds.

    (3) record of 4 channels for one second to the sampling frequency of 50 KHz.

    At present, the problem is for the first edition of this program, two seconds (rather than) data was saved and corn, the error message 200279.

    II. I revised for the second edition of the structure of the producer and the consumer who can increase the speed of the buffer.

    The question is how to configure the trigger to start the backup of data and limit data save for one second whenever the set point value changes.

    (1) which edition is best for my application?

    (2) how to trigger the data record?

    (3) how to record only a second of data?

    I also checked this announcement and the elapsed time seems not to work for this case.

    Any help would be greatly appreciated!

    Melody

    Hello

    you have not used properly the nodes property.

    1. replace the case structure in the first loop, with DAQmx features, with a structure of the event. Change the event fires for a worth of control of the setpoint change.

    Edit: as stated in your first post, use the structure of the event, but put inside the while loop.

    2. DO NOT connect error output from the stop command property node. Replace it with a local variable for the stop button.

    Try these and let me know.

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • Code of the trigger with the error table mutation

    I have 2 tables, cc_call_lists and cc_call_issues. I have a trigger on the table of cc_call_issues so that when the priority is updated I can determine how to set Issue_Priority.

    Basically, the priority update for an Issue_Id I need to update the I want to watch Issue_ids of all the participating on the cc_call_lists table and determine how to update the Issue_Priority column.

    Issue_Priority must always be the first priority of the table cc_call_issues for Issue_id records in the cc_call_lists table. So when I need to watch all changes priority priority values for which the Participant has records in the cc_call_lists table and take the max value priority after the record is updated.

    Unfortunately, I get the following error message when the trigger is activated:

    ORA-04091: table TTMS. CC_CALL_ISSUES is changing, function of triggering/can not see
    ORA-06512: at «TTMS.» UPDATEISSUEPRIORITY', line 30
    ORA-04088: error during execution of trigger ' TTMS. UPDATEISSUEPRIORITY'

    Is there a work around which is not too complicated? Any help would be greatly appreciated.


    Table: cc_call_lists
    Name
    -----------------
    PARTICIPANT_TYPE
    PARTICIPANT_ID
    LAST_ACCESS_DT
    LAST_ACCESS_BY
    CREATE_DT
    CREATE_BY
    MODIFY_DT
    MODIFY_BY
    CALL_STATUS
    CALL_PRIORITY


    Table: cc_call_issues
    Name
    -----------------
    ISSUE_ID
    ISSUE_DESCR
    DEACTIVATION_DT
    PRIORITY
    CREATE_DT
    CREATE_BY
    MODIFY_DT
    MODIFY_BY

    Trigger on cc_call_issues code:
    CREATE OR REPLACE TRIGGER TTMS.UpdateIssuePriority
    BEFORE UPDATE
    OF PRIORITY
    ON TTMS.CC_CALL_ISSUES 
    REFERENCING NEW AS New OLD AS Old
    FOR EACH ROW
    DECLARE
    tmpMaxPriority number:=0;
    
    -- Get list of all participants call queue records, existing priority who also have a participant issue record with this issue code
    cursor c1 is
    select a.participant_id, a.call_priority
    from cc_call_lists a, cc_participant_issues b
    where 
      a.participant_id = b.participant_id
      and b.issue_id = :new.issue_id
      and b.issue_status = '001'
      and a.call_status <> '003';  -- Not closed already
    
    BEGIN
        for thisone in c1 loop
                -- Get the existing highest priority
                select nvl(max(b.priority),0)
                into tmpMaxPriority
                from cc_participant_issues a, cc_call_issues b
                where
                  a.issue_id = b.issue_id and
                  a.participant_id = thisone.participant_id;
                  
                -- Update it if the new priority value is higher than the existing call queue record priority
                if :new.priority > tmpMaxPriority then
                        update cc_call_lists
                        set call_priority = :new.priority
                        where participant_id = thisone.participant_id; 
                elsif :new.priority < tmpMaxPriority then
                        update cc_call_lists
                        set call_priority = tmpMaxPriority
                        where participant_id = thisone.participant_id; 
                end if;
        end loop;
    END UpdateIssuePriority;
    /

    Move the level of LINE at the STATEMENT level triggers, see:
    http://www.Oracle-base.com/articles/9i/mutating-table-exceptions.php
    http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551198119097816936

  • trigger error autnomous mutation! Why not allow select in the trigger body?

    case 1. a user updates the table and this user has not committed, even fire user select request, he would get an old result. but no error.

    case 2. We have table x, trigger appears on the table x as soon as the table is updated to trigger fires. inside the body that we select just for table 'x' it throws error error changing table
    can someone please explain why?

    my example as follows:
    case 1:
    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myTable VALUES (1);
    commit;
    INSERT INTO myTable VALUES (2);

    Select * from myTable;
    C1
    ------------
    1




    case 2:
    CREATE TABLE myMaxTable
    (maxValue NUMBER);

    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myMaxTable VALUES (NULL);
    COMMIT;

    CREATE OR REPLACE TRIGGER myTrigger
    AFTER ON INSERT myTable
    FOR EACH LINE
    BEGIN
    UPDATE myMaxTable
    SET maxValue = (SELECT MAX (c1) FROM MaTable);
    END;
    /
    INSERT INTO myTable VALUES (1);

    INSERT INTO myTable VALUES (1)
    *
    ERROR on line 1:
    ORA-04091: table HUNBUG. MYTABLE is changing, function of triggering/can not see
    ORA-06512: at "HUNBUG. MON_TRIGGER', line 2
    ORA-04088: error during execution of trigger ' HUNBUG. MYTRIGGER'

    Assume that you are doing something like this:
    You have three records in the table:

    INSERT INTO myTable VALUES (1);
    
    INSERT INTO myTable VALUES (2);
    
    INSERT INTO myTable VALUES (3);
    

    Then do you one insert call to do more than three:

    INSERT INTO myTable
    SELECT c1 + 100
    FROM myTable;
    

    This last call insert inserts 3 records in your table - 101, 102 and 103.

    When you have a trigger FOR EACH ROW, which will be called three times, but there is no way to predict in what order, and when the trigger will fire for example at c1 = 102, the table is the "mutation" - it is located in the heart of a change and you don't know if 101 or 103 or both is in the table. Oracle does not allow you to do a select on the table of this mutation.

    When you remove the FOR EACH ROW clause, the trigger only will be called once at the end of this call to insert, moment in which the table is no longer changing and so your code will be located safely c1 max.

  • DB trigger error - update even table in the script of the trigger

    Hi all
    I have a table tab1, whenever any update is done on this table on column col1 and col2 also needs to get the update. (These are related to user forms can be updated only col1 form frontend)
    So I created a trigger as follows.
    ----------------
    CREATE OR REPLACE TRIGGER tri1
    AFTER UPDATE
    ON tab1
    FOR EACH LINE
    WHERE (NEW.col1 = 'YES')
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    Tab1 SET col2 = 1 UPDATE
    WHERE transaction_id =: OLD.transaction_id;
    COMMIT;
    END;
    --------
    When there is no update on this table, I get following error. Please let me know if I'm missing something.
    ORA-00060: Deadlock detected while you wait resource
    ORA-06512: at "user1.tab1", line 5
    ORA-04088: error during execution of trigger 'user1.tab1 '.
    Please let me know if I'm not clear. Thank you

    Published by: DharV on August 23, 2011 05:17

    Your transaction_id is unique?

    If this is the case, then you could perhaps use AFTER UPDATE BEFORE 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 - if you really want to update more than one line in tab1 - your update cannot update the same line that the trigger has responded, even with the use of an autonomous transaction. Then you could combine the BEFORE UPDATE trigger above with your own AFTER UPDATE, but then add ROWID! =: OLD. ROWID to where clause, but it would be a bad idea because some of your lines will be updated in a single transaction and others in another transaction.

    In general the autonomous transaction is not a great way to solve the problem of changing table within a trigger. I hope that you have a unique transaction_id and can do BEFORE the UPDATE - if it is then a better way is to save the update id in an overall picture in FOR EACH ROW triggers, and only then AFTER an UPDATE fire is NOT "for each line" update the list of saved IDs

  • What trigger use to change the value of the front element validate trigger

    Hello

    I would like to have an element of the DATE where it is possible to enter values as 1 + 12,-1, which should respond to the evolution of the value of the element to SYSDATE-/ + X. How should I do?

    Now, when I get out of the question, I get a validation error because the value of the element is not a valid date. How can I change the value of the date before it is validated?

    Concerning

    Create a non-base of data-element with the char data type.
    Fill the element in the POST-QUERY-trigger with the value of the date element of the basis of something like

    :BLOCK.THECAHRITEM:=TO_CHAR(:BLOCK.THEDATEITEM, 'DD.MM.YYYY');
    

    Then in the WHEN-VALIDATE-ITEM, check if the user entered a valid date, then simply write to the database column, otherwise check a valid value you want to treat, make the appropriate conversion and rewrite the date you got in the article database and the database element.

Maybe you are looking for