Is the sequence of the insert/update issue?

Dear friends
I wanted to know if there is a difference in the results, if I change the sequence of Insert/Update statements. For example, if I insert / update of the records in a table, normally I write my code like below

< code >

Begin
Insert in the Table Name (...)
Values (...);
Exception
When Dup_Val_On_Index then
Update entire Table name
Column_Name = Value;
While others then
SQLERRM;
End;

< code >

Lets assume, if I change the order of statements like below:

< code >

Begin
Update entire Table name
Column_Name = Value;
If Sql % NotFound then
Begin
Insert in the Table Name (...)
Values (...);
End;
Exception
While others then
SQLERRM;
End;

< code >

If this change makes no difference in the bottom line?

I highly recommend the use of MERGE - make an update-so-insertion or insertion-so-update leaves you open to the clashes during two sessions try and add a new line at the same time.

If you are not able to use MERGE for whatever reason, then I would work out who is most likely to happen - an insert or an update and do that first, followed by the other in the exception.

For example. If your system inserts rows into the table in question a lot, but only updates rarely, so first the insert and manage the update in the exceptions. Conversely, if your system updates a lot but doesn't insert only rarely. In this way, you are minimizing the amount of work you have to do.

Opt for a MERGER if possible, though. I don't know Oracle Forms, but can you not to call a stored procedure that could do the MERGE if you are not able to use MERGE directly in forms?

Tags: Database

Similar Questions

  • How to find the insertion, update the schema

    Hello


    I want to follow insert, update, or delete to onparticular the database schema.


    your early repsone is appreciated.



    Thanks in advance.

    user647572 wrote:
    Thank you for your kind reply... It is very useful to me...

    Sorry, but I use under request and

    EXTENDED_TIMESTAMP as a timestamp, type of zone data...

    SELECT SQL_TEXT
    Of
    DBA_COMMON_AUDIT_TRAIL
    where EXTENDED_TIMESTAMP between to_date ('20101016 10:30 ', 'HH24 YYYYMMDD')
    and to_date ('20101016 11:00 ', 'HH24 YYYYMMDD')
    AND OBJECT_SCHEMA = 'JISPBILCORBILLINGPRD501. '
    AND UPPER (SQL_TEXT) AS UPPER ('INSERT%')

    It takes more time to display the result.

    This is a normal situation. See the table in the sys.aud$, what folder contains this table?
    You can delete old audit as records

    DELETE FROM sys.aud$ WHERE timestamp# < SYSDATE -40;
    

    >

    Please give me suggestion on this subject...

  • IPad slow since the recent update issues

    iiPad2 games running and very slow Internet as the recent update 9.3.1 seem suspended then loading after a minute or two any other person with this type of problem or suggestions to help solve this thank you

    Go to settings - Safari - clear the history and data from the Web site.

    Reset your network settings.

    Settings - general - reset - reset the network settings

    Reset your device. This will not erase your data stored on the phone.

    • Press and hold the sleep/wake button
    • Press and hold the Home button
    • Press and hold both buttons until the display turns off and on again with the Apple logo on the subject.

    Alternatively, you can go to settings - general - reset - Reset all settings

  • Since the last update issue 31, whenever I start Firefox It controls compabillitity with Add ons

    Every time I start Firefox I get on my desktop check Add ons compabillity and Firefox open, never had this before, how can this be resolved.

    I've updated from version 25 (25.1?) to 31 version and updated all my modules at a time. Whenever I started Firefox it would check compatibility and open the pages for all the Add-ons. I tried all of the suggestions posted here without success. I loaded a backup of my system and just tried to update the add-on and it's the same thing. What I was finally load a backup of my system, delete all the Add-ons, Firefox update and then go back new versions of Add-ons one at a time. It was a chore, but it worked. (In millions of possible computer, millions of unique & fixed issues configurations.)

  • Cannot perform the insert/update on the form of tables, due to the dynamic action

    Hi all

    I created a dynamic action that calculates multiple cells in a table.

    This feature works well, when I change the value of the associated cell then the computed value is changed by the dynamic action.

    But I am not able to insert or update the line in a table when the dynamic action is enabled. When I put the condition 'Never', then the line is inserted or updated without any problems.

    All guess where is the problem?

    Apex version: 4.1.1.00.23

    Jiri

    Nina wrote:

    I don't know why the 123,40 value (or other) is set to the next item in line (f09, fsc, etc.)
    >

    What is hidden and generated Apex elements are always included in the last cell (td) of the line. Thus, it has nothing to do with the next item, only the last cell.
    If you see the last cell of the 888 Page you will see probably the same type = "hidden" entries here also.

    Your problem is not related to the HTML fragment to the last cell in the row showing all those extra items, it's somewhere else.

    Oh, here comes the jQuery selector:

    var clickedRow = $(this.triggeringElement).closest('tr');
    
    $(clickedRow).children('td[headers="SAL"]').find("input").val(myCalculatedTotal);
    

    SAL, COMM, w/e. here you will find the TD with headers = "COMM" and all the input fields and the value of all the entries in total calculated. Your selection is not precise enough in this case.
    So, target the specific entry.
    With the code example:

    
    
    
    
    
    
    
    
    

    change the switch on

    $(clickedRow).children('td[headers="SAL"]').find('input[name="f08"]').val(myCalculatedTotal);
    
  • Optimization of the insert/update procedure

    My requirement is to insert into the TEST table using the select query.
    If the new record found then insert into the table
    Otherwise update the table with the procedure in the p_dt and p_bno parameters.
    I've written as below. It works fine,
    But you want to optimize the code.
    Could you help me in this.
    create table test (o_id number,rt_cd varchar2(11),fator varchar2(11),l_ind varchar2(11),
    up_dt date,bc_no number)
    
    
    create or replace procedure proc_test ( P_dt DATE ,P_bno NUMBER)
     IS
      cursor c_nm is
        select distinct a.id vo_id,b.r_cd vrt_cd,null vfator, 'C' vl_ind,p_dt up_dt,p_bno bc_no
         from test1 a,test2 b
           where a.id =b.id
    BEGIN
      BEGIN
       insert into test (
         o_id,rt_cd,fator,l_ind,up_dt,bc_no)
       select * from (select distinct a.id vo_id,b.r_cd vrt_cd,null vfator, 'C' vl_ind,p_dt up_dt,p_bno bc_no
         from test1 a,test2 b
           where a.id =b.id) T
        where not exists (select 1 from test t1
                           where T.o_id = t1.o_id
                             and T.r_cd = t1.r_cd );
        commit;
       Exception when others then
         DBMS_OUTPUT.PUT_LINE(' In Error'|||| SQLCODE|| '-'|| SQLERRM);
     
      for i in c_cur loop
       update test 
        set o_id =i.vo_id ,rt_cd =i.vrt_cd,fator =i.vfator ,l_ind =i.vl_ind,up_dt=p_dt ,bc_no =p_bno
        where o_id=i.vo_id and rt_cd =i.vrt_cd ;
       end loop;
      commit;
     exception when others then
         DBMS_OUTPUT.PUT_LINE(' Main Error'|||| SQLCODE|| '-'|| SQLERRM);
     end;
    Could you help me in this.
  • Someone at - he of the recent update issues?

    I updated last week and immediately my membership became a trial and not paid. Technology bumbled autour with it until it has been fixed, thinks. Now, hearing is missing on my computer and programs to update again. Anyone see this?

    Please see the links below.

    Also, make sure you use the right adobe ID to log in.

    Hope this will help you.

    Kind regards

    Hervé Khare

  • How to capture the result of the INSERTION/update in a variable?

    Hi friends, look at this:

    SQL > UPDATE MyTable SET MyColumn = 100;
    -1000 lines to update

    How do I capture the message "1000 rows updated" in a variable in a stored procedure?

    Concerning

    after update stmt writing below stmt in the procedure;

    dbms_output.put_line (' lines = ' |) TO_CHAR(SQL%ROWCOUNT));)

    Published by: J2EE_Life on April 26, 2012 08:40

  • Restrict the insert, update, delete the other user table

    I created a new database user. I have granted the privileges system into a TOAD.

    • Select any table
    • alter any table
    • delete a table

    I found that account can select, alter, drop table arrays of other schema. So how I can limit the which account to modify, remove only its tables belonging and select table of all the schema?

    Is there the ALTER table, ALTER view, ALTER procedure, ALTER synonym, DROP table, DROP view, DROP procedure, DROP synonym system privileges? How can I grant it without ANY system privileges?

  • Can't get the lines updated in IFL type3?

    Hello

    I'm implementing the CPC type3.

    To do this, I used the updated incremental sql ikm & oracle ckm.

    I opened ikm & duplicate the command update of existing lines. I changed the query.  and

    target also source mapping to the table, I changed the keys ud. I HAV eupdated smith Sani 800 to 30000 after execution, I had the current value of sal & I have no previous data salary.

    Thanks to this link, I'm impleneting IFL 3

    http://www.odigurus.com/2012/01/SCD-type-3.html

    SCD Type3 in team ODIDW

    again, I have no previous data.

    Please help me.

    Thanks in advance,

    a.Kavya

    err9.jpg

    err10.jpg

    err5.jpg

    err6.jpg

    err7.jpg

    err8.jpg

    You can simulate the code (if you have this option in the 11g version) OR run the task and the operator to control and check what is the INSERT/UPDATE request, it generates at run time?

    Run the query even in your DB to check the issue...

  • Performance of insert/update SQLite

    Hi guys,.

    I tested module database in our application. I'm quite satisfied with the speed of select queries. I took ~0.1-0.3 seconds for large queries. But the insert/update quries, to 2-3 sec per operation. You have the same numbers?

    I read on temporary tables. Do you know other ways to speed up insertions/changes?

    Thank you

    Eugen

    I did a few tests.

    So packing several updates significantly increase the time of:

    20 insert/update statements ~ 45-53 seconds

    20 insert/update statements in a single transaction ~ 4-8 seconds

    This is an expected according to expirience android behavior.

    Also I tried TEMP tables really looks like fast ~ 1s. But I'm not sure about the test conditions "clear."  I'll play more with him.

  • Component ODI OWB 11 GR 2 How to connect lines inserted/updated to update / delete

    Hi experts,
    I developed an ICT KM which will insert into a target table data line-by-line, I used the ICT_SQL_INCR_UPD_ROW_BY_ROW KM of base provided by oracle, what I noticed, is that this newspaper does not work lines that are inserted as other KMs, after that a little research on the internet discovered that ODI has a function for this , oidRef.setNbInsert, but this doesn't work in OWB KM, it gives this error:
    --------------
    Traceback (innermost last):
    "< String >" file, line 305, inside?
    AttributeError: setNbInsert
    [12: 02:05] Szabo Adorian: org.python.core.Py.AttributeError (Py.java)
    org.python.core.PyInstance.invoke (PyInstance.java)
    org. $0 Python.pycode._pyx64.f (< string >: 305)
    org. Python.pycode._pyx64.call_function (< string >)
    org.python.core.PyTableCode.call (PyTableCode.java)
    org.python.core.PyCode.call (PyCode.java)
    org.python.core.Py.runCode (Py.java)
    org.python.core.Py.exec (Py.java)
    --------------

    Dose - anyone have an ideea how can I connect the inserted, updated, deleted in interface OWB lines (we have a customer who would like tho have this feature)?

    Enjoy a quick response,
    CIPI

    Hi CIPI

    Unfortunately, it is not included, the only possible audit for lines is via JDBC and properties explanations in KM.

    So not every API of ODI is supported, a large common subset is available, you can see the doc for more details (these audit would be useful);
    http://download.Oracle.com/docs/CD/E11882_01/OWB.112/e10935/code_tempates.htm#CIHIIJDI

    See you soon
    David

  • Insert/update stmt does not

    Hello



    I created an region that hides and shows the javascript-based. I had to add a new field in this region and now it will not write to the database, it displays correctly on the form. I copied the field to another field and renames to p12_joint_service_trng. The field is a button that uses a LOV
    It will not write the p12_joint_service_trng to the database and I don't get to her syntax errors. The code works fine.

    The process of the page below:

    INSERT/UPDATE IN DFCY_CATG_TABLE-
    IF: P12_DFCY_SEQNO4 IS NULL and: P12_DFCY_CATG_C IN ('1', '2', '7', '6', '3') THEN
    INSERT INTO DFCY_CATG (DFCY_SEQNO, DFCY_CATG_C, INFRSTRCTR_NARR, OPFORCE_EMP_NARR, PERS_QTY)
    VALUES(:P12_DFCY_SEQNO,:P12_DFCY_CATG_C,:P12_INFRSTRCTR_NARR,:P12_OPFORCE_EMP_NARR,v_dfcy_pers_qty);
    ON THE OTHER

    UPDATE DFCY_CATG
    SET INFRSTRCTR_NARR =: P12_INFRSTRCTR_NARR,
    PERS_QTY =: P12_PERS_QTY,
    OPFORCE_EMP_NARR =: P12_OPFORCE_EMP_NARR
    WHERE DFCY_SEQNO =: P12_DFCY_SEQNO;
    END IF;
    --------------------------------------------------------------------------------------------
    -DFCY_CATG_TRNG INSERT/UPDATE.
    INSERT/UPDATE IN DFCY_CATG_TABLE TRAINING-

    IF: P12_DFCY_SEQNO4 IS NULL and: P12_DFCY_CATG_C = "4" THEN

    INSERT INTO DFCY_CATG (DFCY_SEQNO, DFCY_CATG_C, JOINT_SERVICE)
    VALUES (: P12_DFCY_SEQNO,: P12_DFCY_CATG_C,: P12_JOINT_SERVICE_TRNG);
    ON THE OTHER
    UPDATE DFCY_CATG
    SET JOINT_SERVICE =: P12_JOINT_SERVICE_TRNG
    WHERE DFCY_SEQNO =: P12_DFCY_SEQNO;
    END IF;

    --------------------------------------------------------------------------------------------
    -DFCY_CATG_TABLE_POLICY INSERT/UPDATE.

    IF: P12_DFCY_SEQNO4 IS NULL and: P12_DFCY_CATG_C = '5' THEN
    INSERT INTO DFCY_CATG (DFCY_CATG_C, JOINT_SERVICE, DFCY_SEQNO, POLICY_DOCTRN_NARR)
    VALUES (: P12_DFCY_SEQNO,: P12_DFCY_CATG_C,: P12_JOINT_SERVICE,: P12_POLICY_DOCTRN_NARR);
    ON THE OTHER
    UPDATE DFCY_CATG
    SET JOINT_SERVICE =: P12_JOINT_SERVICE,
    POLICY_DOCTRN_NARR =: P12_POLICY_DOCTRN_NARR
    WHERE DFCY_SEQNO =: P12_DFCY_SEQNO;
    END IF;

    Thanks for the help,
    Mary

    Published by: Lucky on February 9, 2010 15:09

    Mary:

    Check the sesion State browser and verify that the referenced page objects in the "INSERT/UPDATE DFCY_CATG_TRNG-' you are blocking the page-process code have expected values."

    CITY

  • What is the best way to store the RCS for an insert/update in this rec

    Oracle on Win 64 non-conteneur 12.1.0.2

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    I thought of a line after trigger, but did not know if this trigger to store the current_scn would still fire that trigger again (recursive trigger).

    Someone at - he a good idea of what the best way is to do?  The devs don't want to store the pk and the SNA in yet another table...

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    3rd party applications retrieve data from tables (all data).  We are looking for a way for them to just pull what is new or updated updated since their last sweater.

    I suggest that you try again and give all OF THE REQUIREMENTS.

    You have rejected ANY answer given and he justified using 'hidden' on what knowledge management or the devs want or do not want to. Stop making us guess what are the requirements and constraints. If you want a real answer then tell us ALL the news.

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    Solomon answered repeatedly. If you want to add a column to a table to store the then "best" SNA is to let the Oracle to do this for you automatically by using the DEPENDENCY LINE.

    As he says also re-create the table to add this clause will be MUCH MORE EFFECTIVE that everything THAT you can do it manually. It will be also more accurate because Oracle will fill the value ORA_ROWSCN with the SNA at the time the line was committed. You, as long as user, can't fill a column in function when a line is engaged since real VALIDATION belongs to a transaction, not the line or the trigger that you use.

    Yes - there are two drawbacks to this method:

    1. you need to re-create the table

    2. you cannot add an index to this "hidden" column

    The devs don't want to store the pk and the SNA in yet another table...

    Then? Who cares what the devs want to do? You want the BEST solution? Next, you will need to put aside personal preferences and determine what is the 'best' solution. Why it is important that certain dev wants to do this or not?

    OK, the problem of biz is now, 3rd party external users are an all-wheel drive large number of tables in the database via the API that we wrote.  That was obviously interrupted OLTP during the day.  To reduce to the minimum, we want for them just to extract data that has been inserted/updated since their last sweater.

    It is the definition of a "replica" DB Then why don't you consider a real replicated DB? You can use DataGuard and have replicated DB which is read only that can be used to generate reports. Oracle does ALL the work to keep ALL the tables in sync. You and your developers do NOTHING!

    We thought that store the RCS higher their last sweater would allow the API to extract only data with YVERT higher than their last data pull CHN.

    OK - except you keep rejecting solutions actually do. Ask you questions about the SNA stored in the same table, but then reject the solution that does this. And then you add your "devs" don't want to store the info in a new table either.

    Then your solutions must ONLY use the replication or Log Miner. The REDO logs have all changes, if you want to extract yourself. Replication (e.g., DataGuard) will use these logs for you to maintain a replicated database.

    We thought about it, but recreate all tables in production with ROWDEPENDENCIES as well as dealing with CF and other dependencies idea this was shot.

    Well you NEVER mentioned you "thought that" and rejected it. And you NEVER mentioned anything about FKs and other dependencies. What is FKs and other dependencies which prevents this working solution? Tell us! Give us ALL the information.

    Wouldn't a trigger AFTER LINE capture the commit YVERT?  Or is after really not after validation?

    No - a trigger has NOT one commit. A trigger runs as a step in a transaction. Validation applies to the entire transaction. Until you, or Oracle, issues a commit, there is NO "committed SNA" to be stored as ORA_ROWSCN.

    You can easily see that for yourself. Create a simple table with dependencies of the line and then update two different sessions.

    create the table emp_scn rowdependencies in select * from emp where rownum<>

    Select empno, emp_scn ora_rowscn

    Update emp_scn set work = 'b' where empno = 7499

    commit;

    The first SELECT statement will show you that each row has the same SNA.

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622201

    7521,70622201

    Now, do the update (but no commit), then SELECT it

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,

    7521,70622201

    Where is the value of 7499? This session will NOT see a value for the changed lines in the current transaction. Other sessions will still see the old value.

    Now do the validation, then SELECT

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622301

    7521,70622201

    7499 now has a new and different value than the other lines. It will not be this new value until the validation occurs.

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    Well, you got the answer you want. You ask the best way. Now, you say that you were told the best way. But now you don't like the answer.

    How is it our fault? Your question has been answered wasn't she?

    Here are the facts:

    1 oracle creates a history of changes - the REDO log files

    2. you can use Log Miner to extract these changes

    3. you can create your own change log by adding a log file of MV to your table.

    4. you can then write a custom code to use this MV log file to determine which rows to "reproduce".

    So far reject you all THE POSSIBLE solutions.

    Accept it or change the requirements to allow one of the solutions proposed to be used.

    Personally, if I HAD to use a customized solution, I would use a MV journal to record the ROWID of the lines that have changed (for tables ROWID cannot be changed). I would then extract the appropriate lines by pulling on the lines corresponding to these row ID.

    Even that has problems since a line can be changed several times and children lines can also be amended several times - these questions FK you mentioned.

    I suggest you read this entire thread on AskTom a dozen years ago. It addresses ALL these issues.

    https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:16998677475837

    Then in your next reply on this topic give us a summary of where some things with your question and what help you further expect.

  • trigger check the previous record of line before insert/update

    Hi all

    I would like to create a trigger that a customer will not be able to create a new account, if it has a status of "Non-payment".

    CustomerID custNRIC paymentStatus

    ----------------------------------------------------------------

    Non-payment of 200 F7654323A

    It will reject the following statement.

    insert into customer (custID, custNRIC, paymentStatus) VALUES (201, 'F7654323A', 'Good');

    so, how can I go around to solve this issue?

    sqlnoob wrote:

    Hi all

    I would like to create a trigger that a customer won't be able to create a new account, if it has a "Non-payment" statusYou

    You can't do things like that in a trigger.

    It will reject the following statement.

    insert into customer (custID, custNRIC, paymentStatus) VALUES (201, 'F7654323A', 'Good');

    The trigger would dismiss as EVERY other row in the same transaction, if you try to use a trigger.

    You can't stop a trigger to run except by raising an exception and the trigger stop from doing anything for ANY line that the trigger activated on.

    together to define

    CREATE OR REPLACE TRIGGER reject_new_account

    AFTER INSERT OR update ON the client

    FOR EACH LINE

    DECLARE

    PRAGMA AUTONOMOUS_TRANSACTION;

    totover NUMBER (3);

    BEGIN

    SELECT COUNT (*)

    IN totover

    OF THE customer

    WHERE: NEW.nric = customer.nric

    AND: NEW.badstatus = "Non-payment";

    Why are you tring to use an autonomous transaction? All that makes the transaction will NOT be part of the transaction that fired the trigger.

    I know there is a problem with the line 13 ' AND: NEW.badstatus = "Non-payment".»

    so, how can I go around to solve this issue?

    This is the LEAST of your problems. Do NOT try to nontransactional things in a trigger.

    Also, don't try to query the table that the trigger is activated on.

    This is the fundamental question: Oracle is a multi-user system. Other users may be perform DML on the same table at the same time. So any NUMBER that provides this trigger can turn out to be inaccurate when other users post their transactions.

    The best you can do in a trigger is throw an exception. If you do this will affect the complete relaxation and all the lines he treated - not only one line you see that you want to reject.

    A requirement like yours needs to be satisfied by the presence of DML performed using functions or procedures and serialize the customer INSERT/update this transaction that a SINGLE session/user/can perform DML on the table for a client given.

Maybe you are looking for

  • How can I get rid of the words on my lock screen

    OK so I did the last update on my iPhone 5 and now, under the date on the lock screen, there are letters and words that are not really make sense. I guess that my child put them there. I looked through all the settings I can think but cannot find the

  • Disable the animation of 'bookmark this page' prompt?

    How can I turn off or disable animation newly added to the prompt "bookmark this page"? It was possible to press Ctrl + D to insert a bookmark and immediately followed by ENTER.It's is no longer possible, because the small window of dialogue takes so

  • Install the new hard drive in a HP Envy 17 - t - k000 CTO Notebook PC

    17 t-K000 CTO Notebook PC running Windows 8.1 envy The bottom of my laptop is not the access port with the J100 Quad Core. I want to install an SSD in a drive Bay 1 (port 0) and the HD in the drive Bay 2 (port 1). I pulled each screw on the merits of

  • Windows cannot access the specified device, path... .item

    I am the administrator and is not able to access the files to run windows updates, receive internet service this message pops up to everything that I try to open same not open anything in the control panel (windows cannot access the specified device,

  • How to uninstall an old version of Net session?

    I inherited a laptop running Windows XP SP2.  One of the programs is Net meeting, which obviously does more - but I can't uninstall it via Control Panel > Add/Remove programs.  It is not even there.  How to uninstall it? Thank you.