Add value to existing update statement registration

I have a column with values (for Ex: $3000) and now I want to add $1,000.

How can I add to it with just a statement.is update it all the functions to use like add_months?

Note: I don't want to get the 3000 first and add 1000. I'm looking for a direct update to this additional column with $1,000.

Thank you

DECLARE @IncrementValue int

SET @IncrementValue = 1

UPDATE Table1 SET Column1 = Column1 + @IncrementValue

Tags: Database

Similar Questions

  • Essbase "add to the existing values.

    It must add value to data Essbase using ODI.
    For example: in the Essbase cell is a value of 10. In a source of 5 should be in cell 15 Essbase.
    The procedure as a data load using the Essbase rule where I can put the parameter "overwrite the existing values" or "add to the existing values.
    I can do using ODI?

    Of course, I can export Essbase Data Oracle DB, compute new values and return to the Essbase charge. Can be easy way?

    Thank you.

    Hello

    In your interface and under the IKM "IKM SQL for Hyperion Essbase (data") there is an option for a rule to load "RULES_FILE".
    This means that you can use a rule to support essbase, in the State of charge you can set under "Data loading settings" > "add to the existing values.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • ODI Dataload 'Add to the existing value' in Essbase

    ODI 11.1.1.6 supports the function "add to the existing value" for the Essbase data loads or do we need we must always use a rules file?
    We currently using the rule files into the interface to load the Essbase as our ODI 10.1.3. does not support this feature.

    Published by: user729857 on November 12, 2012 07:07

    You should not use a rule of the load, using a load rule provides additional features and it is the optimal way to load data with the essbase KM

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Update statement using unique table with null values

    Hi all

    I want to update the table example table contain columns of c1.c2, c3 as below data

    tab1: -.
    ------------------------
    C1 c2 c3
    1 2 null
    3 null null
    4 5 null
    6 null null
    -----------------------------------------

    now, I want to update each value null to bellows value c3 c3
    for example, the data as below

    C1 c2 c3
    1 2 3
    4 5 6

    How can using the update statement update it please help me

    Thanks in advance
    Bala

    So you can never be sure of your order by...

    SQL> create table tab1 as
      2  (
      3  select 1 c1, 2 c2,  null c3 from dual union all
      4  select null, null, 3 from dual union all
      5  select 4 ,5, null from dual union all
      6  select null, null ,6 from dual
      7  );
    
    Table created.
    
    SQL>
    SQL> select *
      2    from tab1
      3  /
    
            C1         C2         C3
    ---------- ---------- ----------
             1          2
                                   3
             4          5
                                   6
    
    SQL>
    SQL> merge into tab1 t
      2  using (select rowid rid
      3              , c1
      4              , c2
      5              , c3
      6              , lead (c3) over (order by rowid) ld
      7           from tab1
      8        ) v
      9   on (t.rowid = v.rid)
     10   when matched
     11   then update set c3 = ld
     12   delete where c3 is null
     13  ;
    
    4 rows merged.
    
    SQL>
    SQL>
    SQL> select *
      2    from tab1
      3  ;
    
            C1         C2         C3
    ---------- ---------- ----------
             1          2          3
             4          5          6
    
    SQL> 
    

    @Peter: PTR, het is niet koud. Het zonnetje schijnt ;)
    for everyone: no, it's not cold. The Sun is shining.

  • Question about the update statement

    Hi all


    UPDATE table_name
    SET Column1 = value, column2 = value2
    WHERE condition;

    I have an update like this statement. What happens when I run the above statement, when there is no column named Column2 in the table? If it creates a column named column2 and value2 using?

    Instead should first create a new column named Column2 in the table first and then run this update statement?

    Please, someone good to explain.

    Hi, this statement (it is a dml statement) will give an error, because the Column2 does not exist in the table. You must add the Column2 by an alter (ddl statement) statement. Then, you can try to execute your statement.

    Kind regards
    Saby

    Published by: 793420 on September 7, 2010 14:48

    Published by: 793420 on September 7, 2010 14:48

  • Performance issue with the Update statement

    Oracle 10204

    I have a problem related to updaing one performance table.
    only 5000 lines should be updated.
    Hir are some details on the tables/M.V concerned:
    TABLE_NAME     LAST_ANALYZED          NUM_ROWS     SAMPLE_SIZE
    PS_RF_INST_PROD     1/20/2010 1:14:22 AM     7194402          7194402
    BL_TMP_INTRNT     1/27/2010 9:08:54 AM     885445          885445
    NAP_INTERNET     1/25/2010 11:47:02 AM     7053990          560777
    I tried to run the update with two options:
    1. with the plan than oracle choose.
    2. with notes I added.
    In both cases I he collapsed after more than an hour.

    Can any one suggest how to speed it up?

    Below are for the two option tkprof.
    Please note that beside the defualt statistics on those tables i also gathered statistics on two column level as followed:
    BEGIN
      SYS.DBMS_STATS.GATHER_TABLE_STATS (
          OwnName        => 'B'
         ,TabName        => 'BL_TMP_INTRNT'
        ,Estimate_Percent  => 100
        ,Degree            => 8
        ,Cascade           => TRUE
        ,No_Invalidate     => FALSE);
    END;
    /
    
    exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns SERVICE_UID size 254');
    exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns FIX_IP_USER size 254');
    Plan 1
    UPDATE BL_TMP_INTRNT A
       SET A.FIX_IP_USER =
              (SELECT C.PRODUCT_ID
                 FROM NAP_INTERNET B, PS_RF_INST_PROD C
                WHERE B.INST_PROD_ID = A.SERVICE_UID
                  AND B.SETID = 'SHARE'
                  AND C.INST_PROD_ID = B.NAP_SURF_UID)
     WHERE A.TERM_DESC LIKE '%ip%'
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.03       0.02          0          0          0           0
    Execute      1   1166.64    4803.78   17989002   18792167        117           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2   1166.67    4803.81   17989002   18792167        117           0
    
    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 13
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  UPDATE  BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=2 us)
         46   TABLE ACCESS FULL BL_TMP_INTRNT (cr=586400 pr=22228 pw=0 time=15333652 us)
         15   HASH JOIN  (cr=18170453 pr=17931639 pw=0 time=3991064192 us)
         46    MAT_VIEW ACCESS FULL NAP_INTERNET (cr=5659886 pr=5655436 pw=0 time=988162557 us)
    329499624    MAT_VIEW ACCESS FULL PS_RF_INST_PROD (cr=12545734 pr=12311281 pw=0 time=2636471644 us)
    plan 2
    UPDATE BL_TMP_INTRNT A
       SET A.FIX_IP_USER =
              (SELECT /*+ index(b NAP_INTERNET_PK) index(c PS_RF_INST_PROD_PK)*/ C.PRODUCT_ID
                 FROM NAP_INTERNET B, PS_RF_INST_PROD C
                WHERE B.INST_PROD_ID = A.SERVICE_UID
                  AND B.SETID = 'SHARE'
                  AND C.INST_PROD_ID = B.NAP_SURF_UID)
     WHERE A.TERM_DESC LIKE '%ip%'
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.02       0.02          0          0          0           0
    Execute      1   4645.25    4613.70      95783   39798095        735           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2   4645.27    4613.73      95783   39798095        735           0
    
    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 13
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  UPDATE  BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=1 us)
        473   TABLE ACCESS FULL BL_TMP_INTRNT (cr=10461 pr=10399 pw=0 time=4629385 us)
        408   MAT_VIEW ACCESS BY INDEX ROWID PS_RF_INST_PROD (cr=39776109 pr=85381 pw=0 time=4605125045 us)
       1350    NESTED LOOPS  (cr=39784584 pr=84974 pw=0 time=4601874262 us)
        470     MAT_VIEW ACCESS BY INDEX ROWID NAP_INTERNET (cr=23569112 pr=50472 pw=0 time=2544364336 us)
        470      INDEX FULL SCAN NAP_INTERNET_PK (cr=23568642 pr=50005 pw=0 time=2540300981 us)(object id 11027362)
        408     INDEX FULL SCAN PS_RF_INST_PROD_PK (cr=16215472 pr=34502 pw=0 time=2057500175 us)(object id 10980137)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       1300        0.50          4.27
      db file sequential read                     85707        0.51         29.88
      latch: cache buffers chains                     1        0.00          0.00
      log file sync                                   1        0.00          0.00
      SQL*Net break/reset to client                   1        0.00          0.00
      SQL*Net message to client                       1        0.00          0.00
      SQL*Net message from client                     1       14.73         14.73
    ********************************************************************************

    The problem in your update statement that is the query in your set clause is executed many times that there are lines in BL_TMP_INTRNT of 'intellectual property' in their column of term_desc. You mentioned there are about 5000, then the query joining NAP_INTERNET with PS_RF_ISNT_PROD is begun 5000 times.
    The trick is to join only once, be updated using join views - provided that it is preserved - key or by using the merge statement.

    Here is an example:

    SQL> create table bl_tmp_intrnt (fix_ip_user,service_uid,term_desc)
      2  as
      3   select level
      4        , level
      5        , 'aipa'
      6     from dual
      7  connect by level <= 5000
      8  /
    
    Tabel is aangemaakt.
    
    SQL> create table nap_internet (inst_prod_id,setid,nap_surf_uid)
      2  as
      3   select level
      4        , 'SHARE'
      5        , level
      6     from dual
      7  connect by level <= 10
      8  /
    
    Tabel is aangemaakt.
    
    SQL> create table ps_rf_inst_prod (product_id,inst_prod_id)
      2  as
      3   select level
      4        , level
      5     from dual
      6  connect by level <= 10
      7  /
    
    Tabel is aangemaakt.
    
    SQL> exec dbms_stats.gather_table_stats(user,'bl_tmp_intrnt')
    
    PL/SQL-procedure is geslaagd.
    
    SQL> exec dbms_stats.gather_table_stats(user,'nap_internet')
    
    PL/SQL-procedure is geslaagd.
    
    SQL> exec dbms_stats.gather_table_stats(user,'ps_rf_inst_prod')
    
    PL/SQL-procedure is geslaagd.
    
    SQL> set serveroutput off
    SQL> update ( select a.fix_ip_user
      2                , c.product_id
      3             from bl_tmp_intrnt a
      4                , nap_internet b
      5                , ps_rf_inst_prod c
      6            where a.term_desc like '%ip%'
      7              and a.service_uid = b.inst_prod_id
      8              and b.setid = 'SHARE'
      9              and b.nap_surf_uid = c.inst_prod_id
     10         )
     11     set fix_ip_user = product_id
     12  /
       set fix_ip_user = product_id
           *
    FOUT in regel 11:
    .ORA-01779: cannot modify a column which maps to a non key-preserved table
    

    Join is one key kept in the case of b.inst_prod_id and c.inst_prod_id are unique. Please refer to the documentation for more information here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3055

    SQL> alter table nap_internet add primary key (inst_prod_id)
      2  /
    
    Tabel is gewijzigd.
    
    SQL> alter table ps_rf_inst_prod add primary key (inst_prod_id)
      2  /
    
    Tabel is gewijzigd.
    
    SQL> update /*+ gather_plan_statistics */
      2         ( select a.fix_ip_user
      3                , c.product_id
      4             from bl_tmp_intrnt a
      5                , nap_internet b
      6                , ps_rf_inst_prod c
      7            where a.term_desc like '%ip%'
      8              and a.service_uid = b.inst_prod_id
      9              and b.setid = 'SHARE'
     10              and b.nap_surf_uid = c.inst_prod_id
     11         )
     12     set fix_ip_user = product_id
     13  /
    
    10 rijen zijn bijgewerkt.
    
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'))
      2  /
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  c7nqbxwzpyq5p, child number 0
    -------------------------------------
    update /*+ gather_plan_statistics */        ( select a.fix_ip_user               , c.product_id            from bl_tmp_intrnt
    a               , nap_internet b               , ps_rf_inst_prod c           where a.term_desc like '%ip%'             and
    a.service_uid = b.inst_prod_id             and b.setid = 'SHARE'             and b.nap_surf_uid = c.inst_prod_id        )
    set fix_ip_user = product_id
    
    Plan hash value: 1745632149
    
    ---------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                      | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    ---------------------------------------------------------------------------------------------------------------------------------------
    |   1 |  UPDATE                        | BL_TMP_INTRNT   |      1 |        |      0 |00:00:00.01 |      32 |       |       |          |
    |   2 |   NESTED LOOPS                 |                 |      1 |     10 |     10 |00:00:00.01 |      21 |       |       |          |
    |   3 |    MERGE JOIN                  |                 |      1 |     10 |     10 |00:00:00.01 |       9 |       |       |          |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| NAP_INTERNET    |      1 |     10 |     10 |00:00:00.01 |       2 |       |       |          |
    |   5 |      INDEX FULL SCAN           | SYS_C00132995   |      1 |     10 |     10 |00:00:00.01 |       1 |       |       |          |
    |*  6 |     SORT JOIN                  |                 |     10 |    250 |     10 |00:00:00.01 |       7 |   267K|   256K|  237K (0)|
    |*  7 |      TABLE ACCESS FULL         | BL_TMP_INTRNT   |      1 |    250 |   5000 |00:00:00.01 |       7 |       |       |          |
    |   8 |    TABLE ACCESS BY INDEX ROWID | PS_RF_INST_PROD |     10 |      1 |     10 |00:00:00.01 |      12 |       |       |          |
    |*  9 |     INDEX UNIQUE SCAN          | SYS_C00132996   |     10 |      1 |     10 |00:00:00.01 |       2 |       |       |          |
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - filter("B"."SETID"='SHARE')
       6 - access("A"."SERVICE_UID"="B"."INST_PROD_ID")
           filter("A"."SERVICE_UID"="B"."INST_PROD_ID")
       7 - filter("A"."TERM_DESC" LIKE '%ip%')
       9 - access("B"."NAP_SURF_UID"="C"."INST_PROD_ID")
    
    32 rijen zijn geselecteerd.
    
    SQL> rollback
      2  /
    
    Rollback is voltooid.
    

    And it's your current statement. Please note the number of 5000 in the column begins:

    SQL> UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A
      2     SET A.FIX_IP_USER =
      3            (SELECT C.PRODUCT_ID
      4               FROM NAP_INTERNET B, PS_RF_INST_PROD C
      5              WHERE B.INST_PROD_ID = A.SERVICE_UID
      6                AND B.SETID = 'SHARE'
      7                AND C.INST_PROD_ID = B.NAP_SURF_UID)
      8   WHERE A.TERM_DESC LIKE '%ip%'
      9  /
    
    5000 rijen zijn bijgewerkt.
    
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'))
      2  /
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  f1qtnpa0nmbh8, child number 0
    -------------------------------------
    UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A    SET A.FIX_IP_USER =           (SELECT
    C.PRODUCT_ID              FROM NAP_INTERNET B, PS_RF_INST_PROD C             WHERE B.INST_PROD_ID
    = A.SERVICE_UID               AND B.SETID = 'SHARE'               AND C.INST_PROD_ID =
    B.NAP_SURF_UID)  WHERE A.TERM_DESC LIKE '%ip%'
    
    Plan hash value: 3190675455
    
    -----------------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    -----------------------------------------------------------------------------------------------------------
    |   1 |  UPDATE                       | BL_TMP_INTRNT   |      1 |        |      0 |00:00:00.10 |    5076 |
    |*  2 |   TABLE ACCESS FULL           | BL_TMP_INTRNT   |      1 |    250 |   5000 |00:00:00.01 |       7 |
    |   3 |   NESTED LOOPS                |                 |   5000 |      1 |     10 |00:00:00.02 |      24 |
    |*  4 |    TABLE ACCESS BY INDEX ROWID| NAP_INTERNET    |   5000 |      1 |     10 |00:00:00.01 |      12 |
    |*  5 |     INDEX UNIQUE SCAN         | SYS_C00132995   |   5000 |      1 |     10 |00:00:00.01 |       2 |
    |   6 |    TABLE ACCESS BY INDEX ROWID| PS_RF_INST_PROD |     10 |     10 |     10 |00:00:00.01 |      12 |
    |*  7 |     INDEX UNIQUE SCAN         | SYS_C00132996   |     10 |      1 |     10 |00:00:00.01 |       2 |
    -----------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("A"."TERM_DESC" LIKE '%ip%')
       4 - filter("B"."SETID"='SHARE')
       5 - access("B"."INST_PROD_ID"=:B1)
       7 - access("C"."INST_PROD_ID"="B"."NAP_SURF_UID")
    
    29 rijen zijn geselecteerd.
    

    Kind regards
    Rob.

  • need help with the Update statement

    Hello
    I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.

    THE QUESTION
    / * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
    */

    I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
    SELECT
    s.deactivation_date
    FROM
    (
    SELECT
    a.deactivation_date,
    count(m.mission_id) as nomissions
    FROM
    agents a
    INNER JOIN
    missions_agents m
    on
    a.agent_id=m.agent_id
    GROUP BY
    a.deactivation_date
    ) s
    WHERE
    s.nomissions>7 AND s.deactivation_date IS NOT NULL
    .. .and the code for the first date of deactivation for each year of activation agent
    select 
    a2.deactivation_date
    from
    agents a2
    where a2.deactivation_date= 
    (
    select min(a.deactivation_date)
    from 
    agents a
    where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY'))
    )
    ..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.

    Any help greatly appreciated... :))

    I began to wonder how things would :)

    user8695469 wrote:
    First of all why he chooses the date the earliest of all agents

    UPDATE  AGENTS_COPY AC /* (1) */
    SET     DEACTIVATION_DATE = (
    SELECT  MIN(AGS.DEACTIVATION_DATE)
    FROM    AGENTS_COPY  AGS
    ,       AGENTS_COPY AC /* (2) */
    WHERE   TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */
    )
    

    He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.

    (1): when you do a correlated update it is useful to the table alias that you did right here.

    (2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.

    and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    
    WHERE EXISTS
    (
    SELECT
    a.agent_id,
    count(m.mission_id)
    FROM
    agents a
    /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */
    INNER JOIN
    missions_agents m
    ON
    a.agent_id=m.agent_id
    GROUP BY
    a.agent_id,
    a.deactivation_date
    HAVING
    count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL
    )
    

    Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.

    I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.

    Thank you!

  • The UPDATE statement: view Multi level Inline.

    This is the test case.
    create table source(old_val integer, new_val integer)
    / 
    create table target(val integer)
    / 
    insert into target values(1)
    / 
    insert into target values(2)
    / 
    insert into target values(3)
    / 
    insert into source values(1,4)
    / 
    insert into source values(1,5)
    / 
    insert into source values(2,6)
    / 
    insert into source values(3,7)
    / 
    insert into source values(3,8)
    / 
    commit
    / 
    Now I want to update target.val with source.val and the corresponding condition is source.old_val = target.val

    But source.old_val can have multiple values for a given target.val. You can see in the example. I would like to order by ROWID of source and choose the first record.

    So I wrote an UPDATE.
    SQL> update target t
      2     set (val) = (select new_val
      3               from (select new_val, row_number() over(order by rowid) rno
      4                       from source s
      5                      where s.old_val = t.val)
      6              where rno = 1)
      7   where exists(select null
      8             from source s
      9            where t.val = s.old_val)
     10  / 
     
    3 rows updated.
    and that's what I got.
    SQL> select * from target
      2  / 
     
           VAL
    ----------
             4
             4
             4
     
    SQL> select * from source
      2  / 
     
       OLD_VAL    NEW_VAL
    ---------- ----------
             1          4
             1          5
             2          6
             3          7
             3          8
    I expected the updated as 4,6,7 or 5,6,8 value but don't know why its 4,4,4.

    Just try to understand how this update is underway. Not sure if I am missing something basic.

    NOTE: I'm interested in the behavior of this update statement and not another method to solve the problem.

    Thank you

    Knani.

    Well, I think that it is related to the #374632.1 bug, already discussed in [this thread | http://forums.oracle.com/forums/thread.jspa?messageID=2134151]
    In short, your case should return the error I, ORA - 904.

    Nicolas.

  • How to tune this update statement?

    Hello

    I have to solve the following task:

    Update all rows in table A, which has an appropriate row in table B and save what you have done in a table of newspaper.
    It is possible that there are several assembly lines in the table has a row in table B.

    My first approach is a loop above the table B and do an update of table A for each entry in table B.
    It works and looks like this:

    Table A:
    Number of PK (this is the primary key for this table)
    The KEY number

    Table B:
    Number KEY_OLD
    Number KEY_NEW

    Table of newspaper:
    Number of PK
    Number KEY_OLD
    Number KEY_NEW
    declare
      TYPE PK_TAB_TYPE IS TABLE OF number INDEX BY BINARY_INTEGER;
      v_tab_PK       PK_TAB_TYPE;
      v_empty_tab_PK PK_TAB_TYPE;
    begin
      for v_rec in (select * from table_B) loop
        v_tab_PK := v_empty_tab_PK;  /* clearing the array */
        update table_A
        set    KEY = v_rec.KEY_NEW
        where (KEY = v_rec.KEY_OLD)
        returning PK bulk collect into v_tab_PK;
        if (v_tab_PK.count > 0) then
          for i in v_tab_PK.first..v_tab_PK.last loop
            insert into TMP_TAB_LOG(PK, KEY_OLD, KEY_NEW)
              values (v_tab_PK(i), v_rec.KEY_OLD, v_rec.KEY_NEW);
          end loop;
        end if;
      end loop;
    end;
    Given that the table B can have up to 500,000 entries (and table A has more entries) this solution causes a lot of update statements.

    I'm therefore looking for a solution that offers better performance.

    My second approach was using a correlated update and looks like this:
    declare
      TYPE PK_TAB_TYPE IS TABLE OF number INDEX BY BINARY_INTEGER;
      v_tab_PK            PK_TAB_TYPE;
      v_empty_tab_PK PK_TAB_TYPE;
      v_tab_NewKey    PK_TAB_TYPE;
    begin
      v_tab_PK         := v_empty_tab_PK;  /* clear the arrays */
      v_tab_NewKey := v_empty_tab_PK;
      update table_A a
      set    KEY = (select KEY_NEW from table_B where (KEY_OLD = a.KEY))
      where exists (select 'x' as OK
                         from   table_B
                         where (KEY_OLD = a.KEY)
                        )
      returning PK, KEY bulk collect into v_tab_PK, v_tab_NewKey;
      if (v_tab_PK.count > 0) then
        for i in v_tab_PK.first..v_tab_PK.last loop
          insert into TMP_TAB_LOG_DUB(PK, KEY_OLD, KEY_NEW)
            values (v_tab_PK(i), null, v_tab_NewKey(i));
        end loop;
      end if;
    end;
    Now, I found that a single update.
    The only thing missing in this second approach is the old KEY before the update in the log table.
    But I have no idea how to do to get the old value.
    Is it possible to change this second approach to get the old value of the KEY before the update to write it in the table of the newspaper?

    And now I need your help:
    What is the best way to get a high-performance solution for my task?

    Any help is appreciated.

    Hartmut cordially

    Have you tried my advice to make a UNIQUE on table_B (KEY_OLD) index?

    Oracle wants to make sure that the update statement are left with two different values for the update of a line:
    The keys must be preserved in the online posting.

  • How can I add values beyond the truncation variable environment of path of 1024 bytes on a Windows 7 computer?

    I get an error when I try to update the path in the system variables on my laptop Windows 7, how to add values beyond the limit of 1024 bytes?    Is there another limit or can this solution go beyond the character limit?

    Hi Ronald,.

    Thanks for posting your query in Microsoft Community.

    I understand from your description, that you have problems with the update the path in the system variables. I'll be happy to help you

    1. what you trying to accomplish?

    2. What is the exact error message that you receive?

    3. are you referring to the limit of characters of the file name or the path to the file?

    248 characters for the maximum path length and 260 for the maximum length of file name.

    For more information, you can consult this article:

    File naming, paths and namespaces

    http://msdn.Microsoft.com/en-us/library/aa365247.aspx

    For all windows questions do not hesitate to contact us and we will be happy to help you.

  • Commit to taking a lot of time for the update statement to bulk - 11 GR 2

    Hi team,

    We have a source table, which is the main table for our application.

    When I commit a transaction after update block, it takes long about 2 to 4 minutes.

    I don't understand why it takes too long...

    Could you please help me on this fix, please...

    It's the details on the table,

    Total number of records: 35 M record

    Validation interval: 500 records / commit

    Total scores: 3

    total number of columns: 95 - including primary, unique and foreign key columns (all columns will be updated for each update because update from the app online)

    Total no of the foreign key columns: 12

    Unique key column: 1

    Total index: 27 ( including the key index foreign 12 + 1 + 1 index of primary key Unique key index )

    example of update statement,

    UPDATE DIRECTORY_LISTING_STG
    SET
      COLUMN_1 = :VAL_1
      .
      .
      .
      COLUMN_94 = :VAL_94
    WHERE RECORD_KEY = :P_KEY_VAL;
    
    

    The table is.

    Plan hash value: 2997337465
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation          | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | UPDATE STATEMENT   |                       |     1 |   308 |     3   (0)| 00:00:01 |
    |   1 |  UPDATE            | DIRECTORY_LISTING_STG |       |       |            |          |
    |*  2 |   INDEX UNIQUE SCAN| XPKDLS_STG_PARTPN     |     1 |   308 |     2   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("RECORD_KEY"=TO_NUMBER(:P_KEY))
    
    

    Details of the database,

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE 11.1.0.7.0 Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    
    

    Thank you

    RAM

    2793617 wrote:

    Hello

    I am updating table via an application using Hibernate jdbc connection online.

    If the update statement will be sent to the database in a pack of 500 documents (batch update).

    Thanks Ram

    line-by-line UPDATE is slow by slow transformation

    In Oracle no other session can 'see' upgrade from uncommitted changes.

    The only way to significantly reduce the elapsed time is to have only 1 UPDATE & 1 COMMIT!

  • the update statement modidy

    Hi all

    I have here is the update statement in my code

    UPDATE equip_stg stg

    SET stg.err = 'WRC '.

    WHERE DOES NOT EXIST (SELECT *)

    FROM (SELECT stg.*

    Of equip_stg stg.

    REASON_SETUP sea

    WHERE stg.equipment_fk = mer.equipment_pk

    AND stg.downtime_reason_code = mer.reason_code

    AND ((stg.status = 3 AND sea. REASON_TYPE = 1)

    OR (stg.status = 2 AND sea. REASON_TYPE = 3)

    OR (stg.status = 1 AND sea. REASON_TYPE = 4))

    ERS stg.downtime_reason_code AND IS NOT NULL)

    WHERE ers.equipment_fk = stg.equipment_fk

    AND ers.downtime_reason_code = stg.downtime_reason_code

    )

    AND stg.status IN (3,2,1)

    AND stg.downtime_reason_code IS NOT NULL;

    The statement above sets updated the column equip_stg in WRC if err for corresponding material and reason, there is no line in the REASON_SETUP table.

    I want to change the code above so that the validation above is first done with REASON_SETUP according to equipment and column of type of reason. Is there is no line for this type of material and the reason in this table, then he must hit lookup table.  Example, I have data from equipment EQP1, status = 3, then it should check if REASON_SETUP has everything save for EQP1 equipment and the reasoning of type 1. If she made the next record should be validated on the table otherwise come file should be validated against the lookup table. For the table of choice also I have same join conditions

    STG.equipment_fk = lookup.equipment_pk

    AND stg.downtime_reason_code = lookup.reason_code

    Thanks in advance.

    Kind regards

    Amrit

    Hello

    I think I see.  All lines for each (equipment, reason_type) will be removed completely on a table or another. reason_setup if possible and looking as if this combination never occurs in reason_type.  Another way to say it is that you want only (equipment, reason_type) groups of the best tablle, where reason_type is better than search.  Exactly what made a Request Top - N .  Here's a way to do it:

    UPDATE equip_stg

    SET err_code = "WRC".

    WHERE (equipment, downtime_reason_code) NOT IN

    (

    WITH union_data AS

    (

    SELECT 'A' preference AS, reason_code, reason_type, equipment

    OF reason_setup

    UNION ALL

    SELECT equipment, reason_type, reason_code, 'B' AS preferences

    SEARCH

    )

    got_r_num AS

    (

    SELECT equipment, reason_type, reason_code

    DENSE_RANK () (PARTITION BY MATERIAL, reason_type

    ORDER OF preference

    ) AS r_num

    Of union_data

    )

    SELECT equipment

    DECODE (reason_type

    1, 3

    3, 2

    )

    reason_code

    OF got_r_num

    WHERE r_num = 1

    )

    ;

    To see how this works, reconstruction of the NOT IN subquery, step by step.  First run just union_data as a stand-alone application.  When you understand what it does, run got_r_num and when you see what he's doing, run the set NOT IN subquery.

  • Update statement is a coherent lof 'Get '.

    Hello

    When I run this update statement, it generates a lot of 'get in line ':

    UPDATE PFA_FUSIONFACC WAS

    SET (COD_FACTURA, TOT_CARGO_DB, TOT_CARGO_FB) =

    (SELECT THE NPC. COD_FACTUcaRA AS COD_FACTURA, NPC. TOT_BASEIMPO_E AS TOT_BASEIMPO, NPC. TOT_IMPEMI AS TOT_IMPEMI

    OF NPC, CTA AUX_CTAFACTU PFA_NPCOFACTMES

    where LTC. CTA_FACTURAC = WAS. CTA_FACTURAC

    AND NPC.cod_postal = CTA.cod_postal

    AND NPC.cta_facturac = CTA.cta_facturac)

    where FUS.rowid in

    (SELECT WAS.) ROWID

    NPC PFA_NPCOFACTMES, CTA AUX_CTAFACTU, WAS PFA_FUSIONFACC

    where LTC. CTA_FACTURAC = WAS. CTA_FACTURAC

    AND NPC.cod_postal = CTA.cod_postal

    AND NPC.cta_facturac = CTA.cta_facturac

    AND ROWNUM < 10000);

    9999 filas actualizadas.

    Passed: 01:38:15.47

    Run plan

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

    Hash value of plan: 2048200947

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

    | ID | Operation | Name                | Lines | Bytes | TempSpc | Cost (% CPU). Time | Pstart. Pstop |

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

    |   0 | UPDATE STATEMENT.                     |     1.    62.       |   117 KB (4) | 00:23:27 |       |       |

    |   1.  UPDATE                            | PFA_FUSIONFACC |       |       |       |            |          |       |       |

    |   2.   NESTED LOOPS |                     |     1.    62.       |   117 KB (4) | 00:23:27 |       |       |

    |   3.    VIEW                            | VW_NSO_1 |  9999 |   117 KB |       |   117 KB (4) | 00:23:27 |       |       |

    |   4.     UNIQUE FATE |                     |     1.   478K |       |            |          |       |       |

    |*  5 |      COUNT STOPKEY |                     |       |       |       |            |          |       |       |

    |*  6 |       HASH JOIN |                     |   774K |    36 M |    86 M |   117 KB (4) | 00:23:27 |       |       |

    |   7.        NESTED LOOPS |                     |  2258K |    60 M |       |   101K (4) | 00:20:16 |       |       |

    |   8.         RANGE OF PARTITION ALL THE |                     |  2258K |    32 M |       |  2554 (2) | 00:00:31 |     1.   338.

    |   9.          FULL RESTRICTED INDEX SCAN FAST | PFA_NPCOFACTMES_103 |  2258K |    32 M |       |  2554 (2) | 00:00:31 |     1.   338.

    | * 10 |         INDEX UNIQUE SCAN | PK_AUX_CTAFACTU |     1.    13.       |     2 (0) | 00:00:01 |       |       |

    |  11.        FULL RESTRICTED INDEX SCAN FAST | PFA_FUSIONFACC_I01 |  3923K |    78 M |       |  5358 (2) | 00:01:05 |       |       |

    |  12.    TABLE ACCESS BY ROWID USER | PFA_FUSIONFACC |     1.    50.       |     1 (0) | 00:00:01 |       |       |

    |  13.   TABLE ACCESS BY LOCAL INDEX ROWID | PFA_NPCOFACTMES |     1.    56.       |     2 (0) | 00:00:01 |     1.     1.

    |  14.    NESTED LOOPS |                     |     1.    69.       |    49 (0) | 00:00:01 |       |       |

    | * 15 |     INDEX SKIP SCAN | PK_AUX_CTAFACTU |     1.    13.       |    47 (0) | 00:00:01 |       |       |

    |  16.     RANGE OF PARTITION ITERATOR.                     |     1.       |       |     1 (0) | 00:00:01 |   KEY |   KEY |

    | * 17.      INDEX RANGE SCAN | PFA_NPCOFACTMES_103 |     1.       |       |     1 (0) | 00:00:01 |   KEY |   KEY |

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

    Information of predicates (identified by the operation identity card):

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

    5 - filter(ROWNUM<10000)

    6 - access("CTA".") CTA_FACTURAC "=" WAS ". ("' CTA_FACTURAC")

    10 - access("NPC".") COD_POSTAL "=" CTA ". "" COD_POSTAL "AND"NPC ". "" CTA_FACTURAC "=" CTA ". ("' CTA_FACTURAC")

    15 - access("CTA".") CTA_FACTURAC "(=:B1)"

    filter ("CTA". "CTA_FACTURAC"(=:B1) "

    17 - access("NPC".") COD_POSTAL "=" CTA ". "" COD_POSTAL "AND"NPC ". "CTA_FACTURAC"(=:B1) "

    filter ("NPC". "" CTA_FACTURAC "=" CTA ". ("' CTA_FACTURAC")

    And statistics

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

    1 recursive calls

    13252 db block Gets

    200711795 compatible Gets

    407276 physical reads

    Redo 3550216 size

    837 bytes sent via SQL * Net to client

    1320 bytes received via SQL * Net from client

    3 SQL * Net back and forth to and from the client

    2 sorts (memory)

    0 sorts (disk)

    9999 rows processed

    Rollback Terminado.

    But the query used by the update is much less "gets":

    SQL > SELECT WAS. ROWID

    NPC PFA_NPCOFACTMES, CTA AUX_CTAFACTU, WAS PFA_FUSIONFACC

    2 where 3 DEC. CTA_FACTURAC = WAS. CTA_FACTURAC

    AND NPC.cod_postal = CTA.cod_postal

    4 5 AND NPC.cta_facturac = CTA.cta_facturac

    AND ROWNUM < 10000 6;

    9999 filas seleccionadas.

    Passed: 00:00:20.57

    Run plan

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

    Hash value of plan: 20234272

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

    | ID | Operation | Name                | Lines | Bytes | TempSpc | Cost (% CPU). Time | Pstart. Pstop |

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

    |   0 | SELECT STATEMENT |                     |  9999 |   937K |       | 29298 (2) | 00:05:52 |       |       |

    |*  1 |  COUNT STOPKEY |                     |       |       |       |            |          |       |       |

    |*  2 |   HASH JOIN |                     |   774K |    70 M |    58 M | 29298 (2) | 00:05:52 |       |       |

    |   3.    RANGE OF PARTITION ALL THE |                     |  2258K |    32 M |       |  2554 (2) | 00:00:31 |     1.   338.

    |   4.     FULL RESTRICTED INDEX SCAN FAST | PFA_NPCOFACTMES_103 |  2258K |    32 M |       |  2554 (2) | 00:00:31 |     1.   338.

    |*  5 |    HASH JOIN |                     |  3906K |   175 M |   123 M | 12842 (2) | 00:02:35 |       |       |

    |   6.     FULL RESTRICTED INDEX SCAN FAST | PFA_FUSIONFACC_I01 |  3923K |    78 M |       |  5358 (2) | 00:01:05 |       |       |

    |   7.     FULL RESTRICTED INDEX SCAN FAST | PK_AUX_CTAFACTU |   147K |  1869K |       |  1120 (1) | 00:00:14 |       |       |

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

    Information of predicates (identified by the operation identity card):

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

    1 - filter(ROWNUM<10000)

    2 - access("NPC".") COD_POSTAL "=" CTA ". "" COD_POSTAL "AND"NPC ". "" CTA_FACTURAC "=" CTA ". ("' CTA_FACTURAC")

    5 - access("CTA".") CTA_FACTURAC "=" WAS ". ("' CTA_FACTURAC")

    And statistics

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

    1 recursive calls

    0 db block Gets

    54736 compatible Gets

    53070 physical readings

    0 redo size

    304491 bytes sent via SQL * Net to client

    7814 bytes received via SQL * Net from client

    668 SQL * Net back and forth to and from the client

    0 sorts (memory)

    0 sorts (disk)

    9999 rows processed

    The "PFA_NPCOFACTMES_103" index is partitioned. I don't know if it's related to this issue:

    SQL > select table_name, uniqueness, separated from all_indexes where index-name = "PFA_NPCOFACTMES_103";

    TABLE_NAME UNIQUENES BY

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

    PFA_NPCOFACTMES NON-UNIQUE YES

    SQL > select TABLE_NAME, COLUMN_NAME, position_colonne from all_ind_columns where index-name = "PFA_NPCOFACTMES_103";

    TABLE_NAME COLUMN_NAME POSITION_COLONNE

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

    PFA_NPCOFACTMES CTA_FACTURAC 2

    PFA_NPCOFACTMES COD_POSTAL 1

    Why the update does not generate as much "becomes"?

    Thanks in advance,

    Jose Luis

    I don't know the reason why at first sight, but it is obvious that the inner nested loop was doing a lot of work (full index scan).

    My first thought was to rewrite the query in a merge statement.

    Perhaps leads to a more effective plan and so no need to delve deeper into the issues you have raised ;-)

    merge into FUS PFA_FUSIONFACC

    a_l'_aide_de)

    SELECT

    NPC. COD_FACTUcaRA AS COD_FACTURA

    NPC. TOT_BASEIMPO_E AS TOT_BASEIMPO

    NPC. TOT_IMPEMI AS TOT_IMPEMI

    OF NPC, CTA AUX_CTAFACTU PFA_NPCOFACTMES

    where

    NPC.cod_postal = CTA.cod_postal

    AND NPC.cta_facturac = CTA.cta_facturac

    ) cta

    (TBT. CTA_FACTURAC = WAS. CTA_FACTURAC)

    When matched then update

    Was SET. COD_FACTURA = cta. COD_FACTURA

    was. TOT_CARGO_DB = cta. TOT_BASEIMPO

    was. TOT_CARGO_FB) = cta. TOT_IMPEMI

    where ROWNUM<>

  • How to optimize the update statement so that the query is reading the same table?

    Hi all

    I have a process with the following UPDATE statement:

    Sales_val update

    SET ship_date =)
    Select max (hist.ship_date)

    FROM sales_hist hist

    WHERE hist. X_ID = A.X_ID

    AND hist. X_VAL = A.X_VAL)

    ) WHERE EXISTS (select * from sales_hist hist where )

    WHERE hist. X_ID = A.X_ID

    AND hist. X_VAL = A.X_VAL

    )

    sales_val - 50 lines mln (unique index)

    sales_hist - 20 mln ranks (unique index)

    I met many problems with waits and locks - how to optimize to avoid locks using the parameters of tables or changes of the declaration? or maybe is there another way to do optimization ?

    Kind regards

    Bolo

    Thank you for that. Collect in bulk Unfortunatelly + FORALL does not work with the types in 10g - solution is to use the FOR loop and is not as effective as FORALL in many cases. I do still some tests to solve this problem - I'll put you once it's done.

    EDIT: hash partitioning + fusion - 3-5 minutes (time), so for now it's the solution to the problem. Thank you all for the great discussion!

  • To add values in a multi-record block in oracle forms 6i

    S. n

    Agenda

    Quantity

    1

    KEYBOARDS

    5

    2

    MOUSE

    6

    3

    MONITOR

    2

    4

    CENTRAL PROCESSING UNIT

    4

    TOTAL quantity

    17

    Hello world

    He is an example for adding records in this block. I need to add the values of the quantity of each time when it has updated. Entering the first record(value=5) the total should display 5. When you enter the second value(value=6) the total should be 11. And if it changes in accounts are rendered already entered the total value must be updated. Please help me do this in oracle forms.

    Hey, Moris,.

    For the contents according to your requirement, create a block and put an element contained in this block that reside on the same canvas.

    Then below mentioned property BLOCK for newly created block:

    • Single disc: Yes

    Then set below mentioned ELEMENT of property for the newly created item:

    • Data type: number
    • Method of calculation: 'summary '.
    • Text-to-speech function: "sum".
    • Block in summary: block that you created
    • Point summary: Point you have created

    I hope it will work for you, I tested and works great.

    Thank you

    Nilesh Goswami

Maybe you are looking for

  • Image on both monitors synchronization script

    So I have two monitors and several dual screen wallpapers I want to be able to scroll. I have an Applescript script that I got from these forums that someone wrote for this purpose, but I get an error that I can't solve everything. The idea is that t

  • How to remove "recently added" music music iOS app?

    Annoyingly, the iOS adds a section of music called "Recently added." I can't remove it, and it holds 894 songs that I bought in recent months. They pigs up to a huge 18 GB of space, I want to use for the music and playlists I want on my iPhone. Why A

  • Uninstall older versions

    Hello: I would like to know if it is safe to uninstall the old security updates for example, Java, and Microsoft Visual C++ I several installed updates. I am suspect of the April security updates from my PC has been reset on its own since then. Thank

  • "You have unsent messages in your Outbox. You want to send now? Yes No.

    "You have unsent messages in your Outbox. You want to send now? Yes No. After pressing on Yes and reload and stop several times in Windows 7 Windows Live Mail the message comes back. I looked and most responses are for Windows Mail and Windows Vista.

  • Dehaze cursor disappeared

    Hi allI have a subscription to the CC and the last update of Lightroom and Photoshop.  My cursor dehaze disappeared.  It has worked very well since this feature became available, but today at photo editing, I noticed he was missing. I used several ti