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.

Tags: Database

Similar Questions

  • ERRORS in the LOG of the capture of 2291 on UPDATE statement errors

    We are running Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - Production 64 - bit with the options of partitioning, OLAP, Data Mining and Real Application Testing

    We used often successfully the clause of the logging of errors during the execution of the batch to the database inserts. However, we now have a situation where an UPDATE statement is default and make back up when it encounters a referential constraint foreign key [ORA-02291]. It registers with success of coercion errors [ORA-02290] Check. Foreign keys are not carried over, and they have nothing to do with unique constraints or indexes on the table that is the target of the UPDATE statement. The logging of errors table was created using the DBMS_ERRLOG package. We have created to make sure that we introduced column format errors. The same problem occurs. The UPDATE statement tries to update about 12000 lines. Any help in understanding this problem would be appreciated.

    Here's the error statement
    ORA-02291: integrity constraint (OIFS. FRAME_FK07) violated - key parent not found

    Here is the statement of the problem and its PLSQL block surrounding:

    BEGIN < < update_records > >
    UPDATE image f
    SET (company_name,
    address1_line,
    address2_line,
    address1_city,
    address1_state,
    address1_zip,
    contact1_name,
    contact1_phone_number,
    update_date,
    update_user,
    -Comments,
    facility_name,
    facility_type,
    doing_business_as,
    contact1_phone_ext,
    contact1_fax,
    contact1_email,
    contact2_name,
    contact2_phone_number,
    contact2_phone_ext,
    contact2_fax,
    contact2_email,
    source_survey,
    source_status,
    address2_city,
    address2_state,
    address2_zip,
    facility_location_number,
    attention_line,
    company_official,
    facility_irs_code
    ) =
    (SELECT company_name,
    address1_line,
    address2_line,
    address1_city,
    address1_state,
    address1_zip,
    contact1_name,
    contact1_phone_number,
    SYSDATE,
    user_in,
    facility_name,
    facility_type,
    doing_business_as,
    contact1_phone_ext,
    contact1_fax,
    contact1_email,
    contact2_name,
    contact2_phone_number,
    contact2_phone_ext,
    contact2_fax,
    contact2_email,
    source_survey,
    source_status,
    address2_city,
    address2_state,
    address2_zip,
    facility_location_number,
    attention_line,
    company_official,
    facility_irs_code
    Oifs.respondent r
    WHERE r.cin = f.cin
    )
    WHERE f.cin IN
    (SELECT cin
    Of
    (SELECT cin,
    company_name,
    address1_line,
    address2_line,
    address1_city,
    address1_state,
    address1_zip,
    contact1_name,
    contact1_phone_number,
    facility_name,
    facility_type,
    doing_business_as,
    contact1_phone_ext,
    contact1_fax,
    contact1_email,
    contact2_name,
    contact2_phone_number,
    contact2_phone_ext,
    contact2_fax,
    contact2_email,
    source_survey,
    source_status,
    address2_city,
    address2_state,
    address2_zip,
    facility_location_number,
    attention_line,
    company_official,
    facility_irs_code
    OF oifs.respondent
    LESS
    SELECT cin,
    company_name,
    address1_line,
    address2_line,
    address1_city,
    address1_state,
    address1_zip,
    contact1_name,
    contact1_phone_number,
    facility_name,
    facility_type,
    doing_business_as,
    contact1_phone_ext,
    contact1_fax,
    contact1_email,
    contact2_name,
    contact2_phone_number,
    contact2_phone_ext,
    contact2_fax,
    contact2_email,
    source_survey,
    source_status,
    address2_city,
    address2_state,
    address2_zip,
    facility_location_number,
    attention_line,
    company_official,
    facility_irs_code
    OF oifs.frame
    )
    )
    ERROR IN oifs.frame_load_errors LOG
    (job_num |) ' ' || TO_CHAR (SYSDATE, 'YYYYMMDD HH24:MI:SS'). 'update')
    REJECT LIMIT UNLIMITED;
    EXCEPTION
    WHILE OTHERS THEN
    ohub.err_pkg.record_and_continue (' msg_in = > ' problem to update the lines of FIELD ');
    LIFT;
    END update_records;

    I think and that's just a wild guess, is that your table has a trigger... or an associated view has a relaxing place.

  • Problem with instructions to update within the if statement

    Hello

    I have the following PL/SQL script. It was written in a way so it can be run several times, without worrying about if she has previously run means that it should only perform the update and edit, if it has not already been done.

    DECLARE
    CNT NUMBER;

    BEGIN
    -Rename column
    COUNT (*) of SELECT INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY ';

    IF (cnt = 1)
    THEN
    UPDATE WELL_TEST_DATA_QUERIES
    THE PRIMARY VALUE = 0
    WHERE PRIMARY = 1;

    RUN IMMEDIATELY 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE;


    END IF;
    END;

    However, when it is executed several times, it seems to execute the body of the if statement each time, despite the fact that the select statement must return a count of 0 (and I checked that this is the case).

    If I change the script and put the UPDATE statement in an EXECUTE IMMEDIATE, it works fine:

    DECLARE
    CNT NUMBER;

    BEGIN
    -Rename column
    COUNT (*) of SELECT INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY ';

    IF (cnt = 1)
    THEN
    IMMEDIATE EXECUTION
    ' UPDATE WELL_TEST_DATA_QUERIES
    THE PRIMARY VALUE = 0
    WHERE PRIMARY = 1';

    RUN IMMEDIATELY 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE;


    END IF;
    END;

    Can someone give me an indication of what is happening here?

    Thank you
    Kathryn

    user10855910 wrote:
    Hello

    I have the following PL/SQL script. It was written in a way so it can be run several times, without worrying about if she has previously run means that it should only perform the update and edit, if it has not already been done.

    Are you referring to getting this:

    SQL> create table well_test_data_queries (primary number);
    
    Table created.
    
    SQL> insert into well_test_data_queries values (1);
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  DECLARE
      2    cnt NUMBER;
      3  BEGIN
      4    -- Rename column
      5    SELECT COUNT(*) INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY';
      6    IF cnt = 1 THEN
      7      UPDATE WELL_TEST_DATA_QUERIES
      8      SET PRIMARY = 0
      9      WHERE PRIMARY = 1;
     10      EXECUTE IMMEDIATE 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE';
     11    END IF;
     12* END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL> select * from well_test_data_queries;
    
    WELL_TEST_TYPE
    --------------
                 0
    
    SQL> DECLARE
      2    cnt NUMBER;
      3  BEGIN
      4    -- Rename column
      5    SELECT COUNT(*) INTO cnt FROM user_tab_columns WHERE TABLE_NAME = 'WELL_TEST_DATA_QUERIES' AND COLUMN_NAME = 'PRIMARY';
      6    IF cnt = 1 THEN
      7      UPDATE WELL_TEST_DATA_QUERIES
      8      SET PRIMARY = 0
      9      WHERE PRIMARY = 1;
     10      EXECUTE IMMEDIATE 'ALTER TABLE WELL_TEST_DATA_QUERIES RENAME COLUMN PRIMARY TO WELL_TEST_TYPE';
     11    END IF;
     12  END;
     13  /
        WHERE PRIMARY = 1;
              *
    ERROR at line 9:
    ORA-06550: line 9, column 11:
    PL/SQL: ORA-00904: "PRIMARY": invalid identifier
    ORA-06550: line 7, column 5:
    PL/SQL: SQL Statement ignored
    
    SQL>
    

    The problem is not because the IF statement entered the swiped m the cnt = 1, but because, when the code is compiled the PRIMARY column does not exist. The code should compile properly against the database, and all verified database object references, until the code is actually running.

    As you have discovered, when you do the dynamic update to help to run immediately, you will not get this problem, because execute immediate statements are strings that can not be validated at compile time and so the code will compile ok and then run.

  • Fix for common problems associated with Windows Update repeatedly trying to solve the same problem

    When the machine running Windows Update on a Windows XP Professional (SP3 with IE8), the information for the download of the ActiveX bar does not appear. Tried to run the Fix for "Common problems with Windows Update" and it says "Windows Update components must be repaired. Difficulty-it short, reports of success, "Found Themes" saying "one or more components of Windows Update are configured incorrectly". However, still unable to download updates from the information bar does not appear. Repeating the difficulty happens with exactly the same problem i.e. reports etc. but no success still can not download the ActiveX on Windows Update since the information bar never shows up.

    At tried all the suggested solutions I can find for the reported similar problems such as checking the downloads ActiveX security settings, reset Internet Explorer settings, and even resetting Windows Update (Articlce ID 971058) components. Still no luck. Therefore, I am unable to manually check and download updates of Windows security.

    Otherwise my PC works well. Norton Internet Security is installed but did not prevent Windows Update to work on another PC I have. The information bar appears sometimes for other downloads, and it doesn't seem to be a problem on the Windows Update page.

    Please can you help. Thank you.

    No, I'm not not first uninstall IE8 (or IE7) before proceeding with the repair facility...

    Long history, technical, short version: do not uninstall IE8 (and/or IE7) before doing a repair installation (Windows XP only!) leaves the two Internet Explorer and Windows in a State of "confused" or "broken". Your only recourse now is a clean install of Windows (after backup your personal data).

    No, another repair facility won't solve the problem - even if you uninstall IE8 beforehand.

    Follow the instructions in this post of mine in another forum (to-the-letter & in order! ) to restore your computer to a State safe & functional: http://aumha.net/viewtopic.php?f=62&t=44636

    If you need additional assistance with the clean install, please start a new thread in this forum: http://answers.microsoft.com/en-us/windows/forum/windows_xp-system

    Note: The computer must NOT be connected to the internet or local networks (i.e. other computers) in its current state. All your personal data (e.g., banking online & passwords credit card) must be considered at risk, if not already compromised.

    Wish I had better news for you.  Good luck!

    PS: So that registry cleaners can solve some problems (temporarily, at least), they are not & cannot fix what caused the problem. Compare to treat a broken leg with a stick and a couple of BandAids.

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

  • 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

  • Handful of division by zero error in the update statement

    My dear welcom

    How and I overcame this problem in my update statement
    for exwmple, it comes to the table
    CREATE TABLE TEST4
    (
    A1 NUMBER,
    A2 NUMBER OF,
    A3 NUMBER
    )

    Insert into TEST4 a1, a2, values (15.3);
    Insert into TEST4 a1, a2, values (9.3);
    Insert into TEST4 a1, a2, values (12.0);

    commit;


    now, I'm trying to update the column a3 in Division a1/12

    Start
    update set of test4
    A3 = a1/a2;
    exception
    WHEN ZERO_DIVIDE THEN
    update set of test4
    A3 = 0;
    end;
    After you validate THE VALUE of A3 = 0;

    Can any onle help me


    I use oracle 10g R2
    Thanks in advance
    SQL> select  *
      2    from  test4
      3  /
    
            A1         A2         A3
    ---------- ---------- ----------
            15          3
             9          3
            12          0
    
    SQL> update  test4
      2     set  a3 = case a2 when 0 then 0 else a1 / a2 end
      3  /
    
    3 rows updated.
    
    SQL> select  *
      2    from  test4
      3  /
    
            A1         A2         A3
    ---------- ---------- ----------
            15          3          5
             9          3          3
            12          0          0
    
    SQL> 
    

    SY.

  • What happens all by issuing the UPDATE statement

    Hi all

    Can you please tell me, what happens when problem user update statement in sga with background process?

    Thank you
    Sanjeev.

    Hope you've finished reading your old post. "what happens all by issuing the select statement.
    What happens all by issuing the select statement

    Open the document since the last post and search "how Oracle database of the LMD processes."

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

  • Problem with the new update

    Any browser looks graphically unstable and content is empty with the new update, is it just me or is just the update which is unstable?

    Hello

    Try disabling graphics hardware acceleration. You will have to perhaps restart Firefox for it to take effect, so save any work first (e.g. you compose mail, documents online that you are editing, etc.).

    Then perform the following steps:

    1. Click the menu button

      then select Options Preferences on Mac or Linux, or Windows.

    2. In the window of Firefox Options (or preferences), click on the Advanced tab, and then select general.
    3. You will find in the list of parameters, the checkbox use hardware acceleration when available . Clear this check box.
    4. Now restart Firefox and see if the problems persist.

    In addition, please check the updates for your graphics driver by following the steps in the following knowledge base articles:

    This solve your problems? Please report to us!

    Thank you.

  • Print problems with the recent update to Version 10.11.5

    Print problems with the recent update to the Version of El Capitan 10.11.5.  Cannot print to my Epson and Samsung printers after update to new IOS.  Print jobs get hooked on my Mac Pro.

    Roger 510 wrote:

    Print problems with the recent update to the Version of El Capitan 10.11.5.  Cannot print to my Epson and Samsung printers after update to new IOS.  Print jobs get hooked on my Mac Pro.

    Have you checked with Epson for an updated printer driver?

  • seems I'm not the only one having problems with safari after update 9.3 cannot follow the links. Safari blocks. hope it gets fixed quickly. jaa shooting allows to follow the link, but the Web page is not out of good old days. any oher ideas?

    seems I'm not the only one having problems with safari after update 9.3 cannot follow the links. Safari blocks. hope it gets fixed quickly. jaa shooting allows to follow the link, but the Web page is not out of good old days. any oher ideas?

    The 'list' of relevant articles that I know, they are now

    -You can read about the problems in the present statutes and possibly find workaround solutions, particularly in the last

    If you are unable to activate your iPhone, iPad or iPod touch after installing an update - Apple Support

    Apple iOS suspension 9.3 updates for older devices, work on activation fix | IVous

    Apple launches new version of iOS for iPad users 9.3 2 affected by bricking bug | 9to5Mac

    GSM of unfixed addresses Apple iPad 2 Bug with revised Activation iOS 9.3, but the larger question remains - Mac rumors

    If you are unable to activate your iPad 2 (GSM model) update to iOS 9.3 - Apple Support

    9.3 iOS update issues

    Leave a post by: ChitlinsCC

  • Satellite Pro L850 1DR - problems with Windows 7 update KB2887069

    I have problems to install the KB2887069 update.

    It seems to install OK... prompt me to restart... when I do it, says it configures... GETS to 7%, then starts rebooting... watch it configures again... up to 7 or 9%... and then reports it is defect and restoring... restarts again... and it is quite... not installed and reference to Windows Update confirms it failed.

    All the other updates I had installed today very well once I realised KB2887069 was the problem and failed to update.

    I am running Win 7 Prof Serv Pack 1 64 - bit on a Toshiba Satellite Pro L850 1DR. I use my AV Microsoft Security Essentials software.

    For now I had to hide the update... but all of the bright ideas how overcome the problem. I tried the Microsoft site, but there is still no answers who brought a solution for me.

    Thanks in anticipation!

    I googled around for KB2887069 update and it seems that you are not alone with this problem to Microsoft Update. I also found your request in the forum, Ms.

    In other words, that's not a problem of mobile by this must be resolved by Microsoft.

    I read in the MS forum on this issue and this issue is still under investigation.

Maybe you are looking for