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

Tags: Database

Similar Questions

  • Do UPDATE statement in line for coherent reading?

    Hi all
    I have a question for the update statement, do UPDATE statement 17Etat for coherent reading? As a statement of pure update: update t set col1 = col1 * 20;

    I'll check with the following steps:
    ######################################
    Preparation: Tables Create1:
    ######################################
    t_update_old (col1 int, col2, col3 float int primary key (2000));

    ######################################
    Preparations: generate data for two tables:
    ######################################
    insert into t_update_old
    Select seq_1.nextval, seq_1.nextval, chr (seq_1.nextval) of double;
    for x in 1.17 loop
    insert into t_update_old
    Select seq_1.nextval, seq_1.nextval, chr (seq_1.nextval) of t_update_old;
    end loop;


    ######################################
    Description of the run
    ######################################
    Create 2 sessions: S1 & S2
    Session S1 updates t_update_old using the following statement:
    Update t_update_old set col2 = col2 * 20;

    S2 session will update t_update_old for a specific line.
    Update t_update_old set col2 is + 1 col2 where col1 = 100000;.

    The two session are performed in the following order:
    1 point in time: S1 began.
    Point in time 2: S2 started.
    Point in time 3: Action update the 100000th ranks in t_update_old by S2 is finished, validation of the transaction in S2 and S2 is finished.
    Point of time 4: update t_update_old of S1 with the 100000th line in t_update_old.
    Point 5 of time: S1 is finished.

    ######################################
    The Question is:
    ######################################
    What is the result of the following statement:
    Select col2 where col1 = 100000;

    100 000 * 20 = 2 000 000
    or
    (100 000 + 1) * 20 = 2 000 020

    By default in Oracle, each SQL statement see data if it exists when begins the execution of SQL statements and the READ COMMITTED isolation level, the effects of each committed transaction are taken into account by statements that start other transactions or validated. The answer is therefore 2 because I understand that the transaction in S2 is committed before start of query in S1.

    Things get complicated if query in S1 starts before request for S2.
    See T. Kyte write notes of consistency:
    http://tkyte.blogspot.com/2005/08/something-different-part-i-of-III.html

  • Im trying to buy photoshop but it keeps saying that its not available in my area. I am in the United States and in my area gets bad! I even updated to the United States, but it is not record the change!

    Im trying to buy photoshop but it keeps saying that its not available in my area. I am in the United States and in my area gets bad! I even updated to the United States, but it is not record the change!

    Hi Mariam,

    It seems that your ID Adobe was initially registered in Pakistan due to which it is not allowing you to make purchases in the United States.

    You can create a new Adobe ID, register in the United States and then it should allow you to make a purchase.

    Let us know if it works or not.

    Thank you

    Yann Arora

  • How to get a update statement faster?

    Hello together,

    I have an update statement on a view in line composed of two tables A and B.

    He works and updates the table column has a value of the corresponding entry in the table B.

    This 1,800,000 update records in table A are updated.

    The table, there are a few clues.

    If I drop the update indexes is much faster (instead of 2,5 hours, that just 0.5 hour).
    But the time needed to re-create the index is much more that I saved thanks to the removal of the index. (4 hours!)

    So I do not remove the indexes and perform the update.

    My update statement runs in mode RBO a uses the FULL (A) - tip to prevent oracle to use the index when you create the inline view (connecting A and B).

    It made a difference for the execution of the update statement if it runs in either CBO or RBO mode?

    What can I do to get faster update statement?

    Thank you very much in advance for any help.

    Hartmut cordially

    You can probably tune.

    Here's a guide that should be useful...

    When your query takes too long...

  • Internal mechanism behind a "update statement"

    Suppose that I published an update statement to change the value of "salary" columns in a table, I does not issue of "committing" again, now when I select the column in my own session, I am able to see the new value, but other users in different sessions can not see the new value for them, I understand that old data is read in the undo tablespace , but for me, the new value source, please explain in detail the inside what is happening behind it.

    Thanks in advance.

    Think of it this way:

    No matter who's going to read a block will recover from the buffer cache (if is not in the cache, it must be read from the disk, but you will get it back in the end of the cache).

    Now, the rules of consistency Oracle reading means that you can 'see' data that is compatible with the point in time that you are interested in (the snapshot SCN). If the data that you read from the buffer cache are 'too new', then your session automatically restores data in the block, by referencing the undo data. This is known as a coherent mode get, as the buffer is recovered pursuant to a specific point in time, or SNA.

    Now, in the case of non-validated data, the transaction is marked as active, so, others Restore automatically, using undo, the previous version of the block. If the session that made the update and still holds the lock (i.e. data only has not yet been validated), Oracle can see that the transaction is the property of the current session and will not restore the data and returns the current data in the data block.

    -Mark

  • Cannot install the update from Microsoft SEcurity Essentials KB2691905 get error the component you are trying to use is on a resource unavailable network

    JOriginal title: can't locate epi.msi

    When you try to install the update of security essentials KB2691905 I get an error message saying "the component you are trying to use is on a network unavailable resource."  «.. . or enter a different path to the folder containing the installation package 'epi.msi' "

    Hello

    Method 1: Install the latest version of the installer

    See the following site:

    Windows install 4.5 Redistributable

    http://www.microsoft.com/en-us/download/details.aspx?id=8483.

     

    Method 2: Clean boot

    See the following site:

    http://support.microsoft.com/kb/310353.

    Note: To set the computer back to start normally, use the procedure How to configure Windows to use a Normal startup state in the same page.

  • What update statement is sent to the database?

    In several pages, I use the Apex line (DML) 4.2 automatic treatment processes. If I do an update of a record, which are columns in the update statement? All columns, only the displayed, only the columns changed, also the PK column?

    As far as I can see now all the columns that are displayed are updated, also the PK, which is display only.

    I ask this, because when the PK is updated (not changed is screen only) all tables in my 75 cases, where this PK is used as FK, will get a lock.

    I did some tests and find out that indeed the Apex is updating all the columns used in the elements by Type of Source is the database column. Even if this item is display only, read-only, etc.!

    My solution now, to prevent the locks, is the following:

    Automated line Fetch:

    Primary key column value containing point: Pxx_ID

    ID of the primary key column: (this is the primary key)

    Pxx_ID (display only, hidden or read-only)

    Source: only when the current value in session state is set to zero

    Source type: static assignment<-->

    Source of value or expression:

    Treatment of automatic line (DML)

    Primary key column value containing point: Pxx_ID

    Primary key column: ID

  • GoldenGate reproducing not UPDATE statement

    Hi all

    I have this problem with my process of goldengate. I created processes extract and replicat process, I was loading initial thru expdp and impdp. All right (insert, delete) until execution of the update statement. He added my replicat process.

    Here is the error:

    2013-07-22 17:05:16 WARNING OGG-01431 abandoned grouped transaction on "OWNER. Table_name', mapping error.

    2013-07-22 17:05:16 WARNING OGG-01003 repositioning of rba in seqno 162688 0.

    2013-07-22 17:05:16 WARNING mapping OGG-01151 error to the OWNER. Table_name to the OWNER. TABLE_NAME.

    2013-07-22 17:05:16 WARNING OGG-01003 repositioning of rba in seqno 162688 0.

    The table does not have the keys to the identifier.

    How should I solve my problem?

    Thank you very much in advance for gurus.

    When you get a mapping error, there will be more details on the issue in the discard file. Take a look here for the error.

    But in general, updates, you must make sure that you did a TRANDATA ADD on the side of the source in order to have the columns, you must apply the operation target and on target, if you do not have a PK or the user interface, you must specify KEYCOLS in the card then Replicat knows which columns to use to format the WHERE clause.

    Let us know what error is in your file throw, and we can go from there.

    Best regards

    Mary

  • problem by making an update statement

    Hi all
    I should write an update statement
    These tables: country: name, code, population, nextyearr_population...
    nextyear_population is empty, first, I should get population_growth of the picture of the population, then compute the year population next according to population and population_growth corrent

    population: country (in fact no code name of the country), population_growth,...

    So I wrote and I got this error
    Error starting at line 1 in command:
    
    update country c
    set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
    )
    where country.code=population.country
    Error at Command Line:4 Column:20
    Error report:
    SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:    
    *Action:
    --------------------------------------------------------
    --  File created - Wednesday-May-15-2013   
    --------------------------------------------------------
    --------------------------------------------------------
    --  DDL for Table COUNTRY
    --------------------------------------------------------
    
      CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER, "NEXTYEAR_POPULATION" NUMBER) 
     
    
       COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
     
       COMMENT ON TABLE "intern"."COUNTRY"  IS 'the countries of the world with some data'
    REM INSERTING into intern.COUNTRY
    SET DEFINE OFF;
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Afghanistan','af','Kabul','Kabul',28513677,647500,null);
    
    
    
    
    --------------------------------------------------------
    --  File created - Wednesday-May-15-2013   
    --------------------------------------------------------
    --------------------------------------------------------
    --  DDL for Table POPULATION
    --------------------------------------------------------
    
      CREATE TABLE "intern"."POPULATION" ("COUNTRY" CHAR(2), "POPULATION_GROWTH" NUMBER, "INFANT_MORTALITY" NUMBER) 
     
    
       COMMENT ON COLUMN "intern"."POPULATION"."COUNTRY" IS 'the country code'
     
       COMMENT ON COLUMN "intern"."POPULATION"."POPULATION_GROWTH" IS 'population growth rate (percentage, per annum)'
     
       COMMENT ON COLUMN "intern"."POPULATION"."INFANT_MORTALITY" IS 'infant mortality (per thousand)'
     
       COMMENT ON TABLE "intern"."POPULATION"  IS 'information about the population of the countries'
    REM INSERTING into intern.POPULATION
    SET DEFINE OFF;
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ad',0.95,4.05);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ae',1.54,14.51);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('af',4.77,163.07);
    Thanks in advance

    I'm using oracle11g and ubuntu 12


    best, david
    update  country c
       set  nextyear_population = population + population * (select pop.population_growth from population pop where c.code = pop.country) / 100
     where  code in (
                     select  country
                       from  population
                    )
    /
    

    SY.

  • Error in update statement

    Hello

    I wrote an update statement as below:

    Update (select a.col1, a.col2 from table1, table2 b
    where a.pk1 = b.pk1 and
    a.PK2 = b.pk2 and
    a.PK3 = b.pk3 and
    a.PK4 in)
    Select a.pk4 from table1, table2 b
    where a.pk1 = b.pk1 and
    a.PK2 = b.pk2 and
    a.PK3 = b.pk3
    less
    Select pk4 from table2
    )
    ) s
    Set s.col1 = 'I ',.
    s.col2 = null;

    Table1 is a base table and the primary key for this table is made of CP1, CP2, pk3, pk4.
    Table 2 is a temporary table with no primary key column.
    My goal is to update the columns of table 1.
    I'm using the code above in a procedure and this error:
    ORA-01779: cannot modify a column that is mapped to a table not preserved key
    I'm sure that the error has to with the foregoing update statement.

    I have read a few articles and realize that Oracle can understand what table to update in this scenario. But I am at a loss to rewrite this query.
    Please advice, how I can rewrite this query.

    Thank you!

    Hello

    Instead of updating a view online, update your actual table, like this:

    UPDATE   table1
    SET      col1     = 'I'
    ,      col2     = NULL
    WHERE      (col1, col2, col3, col4) IN
          (
              SELECT  ...
              FROM    table1
              JOIN    table2  ...
          )
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • Merger of statement: with several Update statement.

    Hello

    I'm trying under the merge statement. However to get the error "not correctly completed 0ra-00933 sql command.

    In fact, my join conditions are the same, but I wanted to update the different columns based on the different places where clause in the update statement.

    for example.

    FUSION
    IN abc3 tgt
    With the HELP of abc CBC
    WE (src.cust = tgt.cust)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.sales = src.sales
    where tgt.cust = 'Cust3'
    UPDATE
    SET tgt.sales1 = src.sales
    where tgt.cust = 'Cust2';

    Please let me know if there is no work around for this.

    Hi, pm

    You can try this please.

    MERGE
     INTO ABC3 TGT
     USING ABC SRC
      ON (src.cust = tgt.cust)
    WHEN MATCHED THEN
    UPDATE SET TGT.SALES = DECODE(TGT.CUST,'Cust3',SRC.SALES,TGT.SALES),
               TGT.SALES1 = DECODE(TGT.CUST,'Cust2',SRC.SALES,TGT.SALES1)
    WHERE TGT.CUST='Cust3' OR tgt.cust='Cust2';
    
  • Decode function in the Update statement

    Hi all

    I'm writing a query where I can update a pastdue_fees column in a table of book_trans based on a difference between the return_dte and due_dte columns.

    I use Oracle SQL. That's what I have so far for my decoding function:

    SQL > SELECT
    2 DECODE (SIGN ((return_dte-due_dte) * 2),)
    3 '-1 ', ' 0',
    4 '1', '12', 'Null')
    5 FROM book_trans;

    DECO
    ----
    Null value
    12
    Null value
    0

    If the logic is that, if the sign is - 1, the value in the return_dte column must be 0; If it is + 1, then it has 12 and everything else is Null.

    So now, I have to conclude my function of decoding of the update statement to update the columns. However, I get the error messages.

    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode (expression)

    I gave him a few different tests with the following results:

    SQL > UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    SET pastdue_fees = SELECT
    *
    ERROR on line 2:
    ORA-00936: lack of expression


    SQL > UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    OF book_trans
    *
    ERROR on line 6:
    ORA-00933: SQL not correctly completed command.

    Any help or advice would be greatly appreciated I got SQL for about six weeks and not very competent!

    Thank you!

    882300 wrote:
    Hi all

    I'm writing a query where I can update a pastdue_fees column in a table of book_trans based on a difference between the return_dte and due_dte columns.

    I use Oracle SQL. That's what I have so far for my decoding function:

    SQL > SELECT
    2 DECODE (SIGN ((return_dte-due_dte) * 2),)
    3 '-1 ', ' 0',
    4 '1', '12', 'Null')
    5 FROM book_trans;

    DECO
    ----
    Null value
    12
    Null value
    0

    If the logic is that, if the sign is - 1, the value in the return_dte column must be 0; If it is + 1, then it has 12 and everything else is Null.

    So now, I have to conclude my function of decoding of the update statement to update the columns. However, I get the error messages.

    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode (expression)

    I gave him a few different tests with the following results:

    SQL > UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    SET pastdue_fees = SELECT
    *
    ERROR on line 2:
    ORA-00936: lack of expression

    SQL > UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    OF book_trans
    *
    ERROR on line 6:
    ORA-00933: SQL not correctly completed command.

    Any help or advice would be greatly appreciated I got SQL for about six weeks and not very competent!

    Thank you!

    If you really really really want to update the entire table, the syntax would be...

    UPDATE book_trans
       SET
          pastdue_fees  = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);
    

    I took out all the single quotes. If you actually have a string column and store all numbers in there so it must be reported as a NUMBER column and not a column of type character (varchar2).

    ALWAYS use the appropriate data type, it will save you a ton of headaches in the future.

    Also, since you are new to the forum, please read the FAQ to learn etiquette and what not.

    http://wikis.Sun.com/display/Forums/Forums+FAQ

  • Need help with update statement to be used in the stored procedure

    I have the following update statement and I get "ORA-06512. Someone of you can help me.

    ----
    UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
    WHERE X.MOID in (UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
    WHERE X.MOID in (A_TEMP_INT1, (select assocchild from mo_association
    Connect prior assocchild = assocparent
    Start with assocparent = A_TEMP_INT1)); (by selecting assocchild in mo_association
    Connect prior assocchild = assocparent
    Start with assocparent = A_TEMP_INT1));
    ----

    Note: A_TEMP_INT1 and A_TEMP_INT3 are the values of cursor and is assigned to numeric values in the code.


    Thanks for all the help in advance.

    Kind regards
    REDA
    WHERE X.MOID IN
     (SELECT ASSOCCHILD   FROM MO_ASSOCIATION
          CONNECT BY PRIOR ASSOCCHILD = ASSOCPARENT
         START WITH ASSOCPARENT = A_TEMP_INT1
         UNION
      SELECT A_TEMP_INT1 FROM DUAL );
    

    Should work.
    VR,
    Sudhakar B.

  • Update statement with Date field

    I'm trying to run an update statement and I want to update the date in the format:

    04/05/2010 12:31:54

    If I run this query on the double it appears correctly: select the double to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM')

    If I run this well query on my table, I get a 'not one month valid' error.


    UPDATE WR_MEASURE_VALUE SET HOST_CORRECTED_VALUE = 35,
    HOST_CORRECTED_DATE = to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM') WHERE WR_MEASURE_VALUE_OID = 474066


    what I am doing wrong and how can I get my update statement to update date correctly in the ' HH12:MI JJ/MM/AAAA: SS PM' form?

    Thank you


    Guess all I had to say was HOST_CORRECTED_DATE = SYSDATE

    Thanks anyway

    Published by: Rich75 on May 5, 2010 07:10

    If you want:

    'UPDATE WR_MEASURE_VALUE SET ' || p_FieldToInsertUpdate || '=' || v_ValueAfterFactored || ',' ||
                                      v_DateToUpdate || '= to_date(''' || to_char(sysdate, 'dd/mm/yyyy hh12:mi:ss PM') || ''', ''dd/mm/yyyy hh12:mi:ss PM'')'||
    ' WHERE WR_MEASURE_VALUE_OID= ' || v_MeasureValueOID_arr(i) ||
    ' AND ' || v_Current_25Month_Value || ' != ' || v_DisplayValue;
    

    But... smacks of dubious design if you do not know what columns you update at compile time, IMO.

  • write an update statement in oracle forms 9i

    Hello

    I have a problematic situation in which

    I get values of a slider and a record group in the drop-down list and text elements block box area two data respectively.
    Both data are read in different tables.

    Now based on the selection of the drop-down list box, I need to update the value selected in another table by writing a statemet update.

    I created a button and the triggering event of when you press the button, I wrote a simple update statement, but it doesn't work like that.

    Kindly help me how to write manual update instructions in oracle forms 9i

    I can't used the buil update in forms that I want to date in a table that is not mentioned in the ownership of the block of data palette

    Help, please

    There is a syntax error in your statement.

    You must write:

    PROCEDURE update_current IS

    BEGIN

    update abc set xculumn= :block_name.item_name2 where ycolumn = :block_name.item_name1 ;

    commit;

    Hope it helps you,

    Fabrizio

    If this answer is useful or appropriate, please mark. Thank you.

    Published by: Fabrizio Delli Priscoli on 23 / ott/2008 14:30

Maybe you are looking for

  • Apple gc charging fees

    My bank account was charged to Gc Apple for $1 on any reason. Does anyone know what's the point? I google and found out that it is the gift card, but I never bought any gift card and I was not buying anything in iTunes recently.

  • I get a corupted file when I run the installer

    I'm with windows 7 and when I run the installer I get a message file corupted

  • Change language Windows NT 3.51

    I know that I'm digging deep here. I need to change the default language of Windows NT 3.51 Workstation from Japanese to English. The computer runs the software that cannot be upgraded or charged on a new installation. Any help is very appreciated.

  • I have 13 updates that are trying to install every time that windows 7 stops

    It's the 64-bit windows. Update tried to install once, then had problems with the installation. He rolled back to a restore point and gave me what he does now. I tried update Fixer in the Panel with no result.

  • Error 0x8DDD0002 - Windows 7 Home Premium - 32-bit

    When I try to update Windows or Office, I get the above error. The address of the link following the problem - HOWEVER - it does not address the problem in Windows 7 and not recommendations that he worked. http://support.Microsoft.com/kb/316524