Is there a faster form of this query?

I received a table of corrections that have to be 'propagated' to a master table, i.e. the corrections table is composed of a few columns and every value of every column of every row must be used to update the corresponding row-column in the master table. Both tables have id columns that can be used to match rows from the two. The query I was given to do this was:
update master a
set a.calculated_error = ( select calculated_error from corrections b where b.id = a.id ),
... additional columns to update follow with the same syntax.
The columns being updated are not indexed in either table.
The query takes a very long time to run. I suppose I can see why, lots of queries on columns that are not indexed so each query involves a table scan.
Is there a faster form of this query?
Thanks,
-=b

In additon to Herald's suggestion, assuming he is correct in his assumption that corrections is small in relation to master, I might also consider updating all of the columns in one shot. something along the lines of:
update master a
set (a.calculated_error, a.first_add, a.second_add) = (select calculated_error, first_add, second_add
                                                      from corrections b where b.id = a.id )
WHERE a.id in (SELECT id from corrections)Alternatively, if corrections.id is unique, I might also try creating a unique index on it and using an updateable join view like:
UPDATE (SELECT a.calculated_error, a.first_add, b.second_add,
               b.calculated_error new_calc, b.first_add new_first,
               b.second_add new_second
        FROM master a, corrections b
        WHERE a.id = b.id)
SET calculated_error = new_calc,
    first_add = new_first,
    second_add = new_secondIf you need to deal with NULLs in corrections, then use something like:
SET first_add = NVL(new_first, first_add)John

Similar Messages

  • Why there is a error in this query ?

    why there is a error in this query ?
    declare
    v_exist pls_integer;
    v_search varchar2(255) := '175';
    v_sql varchar2(255);
    begin
    for s in
    (select table_name, column_name
    from user_tab_columns
    where data_type like '%CHAR%'
    order by table_name, column_name)
    loop
    v_sql := 'select count(*) from '||s.table_name||
    ' where instr('||s.column_name||',' || CHR(39)|| v_search|| CHR(39) ||') > 0';
    execute immediate v_sql into v_exist;
    if v_exist > 0 then
    dbms_output.put_line(s.table_name||'.'||s.column_name||' matches the string.');
    end if;
    end loop;
    end;
    Error:
    The following error has occurred:
    ORA-00933: SQL command not properly ended
    ORA-06512: at line 14
    Edited by: user575089 on Dec 23, 2009 4:14 AM
    Edited by: user575089 on Dec 23, 2009 4:14 AM

    See, Right now i am in schema and see below :
    set serveroutput on;
    declare
    v_exist pls_integer;
    v_search varchar2(255) := 'SCOTT';
    v_sql varchar2(255);
    begin
    for s in
    (select '"'||table_name||'"' table_name,'"'||column_name||'"' column_name
    from user_tab_columns
    where data_type like '%CHAR%'
    and table_name not like '%$%'
    order by table_name, column_name)
    loop
    v_sql := 'select count(*) from '||s.table_name||' where instr('||s.column_name||',' || CHR(39)|| v_search|| CHR(39)||') > 0';
    --dbms_output.put_line(v_sql);
    --execute immediate v_sql;
    execute immediate v_sql into v_exist;
    if v_exist > 0 then
    dbms_output.put_line(s.table_name||'.'||s.column_name||' matches the string.');
    end if;
    end loop;
    end;
    "EMP"."ENAME" matches the string.
    "EXCEPTIONS"."OWNER" matches the string.
    "FLOW_TABLE"."OBJECT_OWNER" matches the string.
    "MYEMP"."ENAME" matches the string.
    PL/SQL procedure successfully completed.
    I am getting output; that i search "SCOTT" word in my search string.

  • Is there any way to tune this query? EXPLAIN PLAN included

    DB version:10gR2
    The below query was taking more than 3 seconds. The statistics are up to date for these tables. Is there any other way i could tune this query?
    SELECT COUNT(1)
    FROM
    INVN_SCOPE_DTL, ship_dtl WHERE ship_dtl.WHSE = INVN_SCOPE_DTL.WHSE (+)
    AND 'QC' = INVN_SCOPE_DTL.FROM_WORK_GRP (+)
    AND  'MQN' = INVN_SCOPE_DTL.FROM_WORK_AREA (+)
    AND  ship_dtl.START_CURR_WORK_GRP = INVN_SCOPE_DTL.TO_WORK_GRP (+)
    AND  ship_dtl.START_CURR_WORK_AREA = INVN_SCOPE_DTL.TO_WORK_AREA (+)
    AND  ship_dtl.WHSE = '930' AND  ship_dtl.OWNER_USER_ID = 'CTZDM'
    OR ship_dtl.OWNER_USER_ID = '*'
    AND ship_dtl.STAT_CODE >= '10'
    AND ship_dtl.STAT_CODE <= '20'
    ORDER BY ship_dtl.OWNER_USER_ID DESC,
    ship_dtl.CURR_TASK_PRTY ASC, INVN_SCOPE_DTL.DISTANCE ASC, ship_dtl.RLS_DATE_TIME ASC, ship_dtl.TASK_ID ASC;
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                      |  Name               | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT               |                     |     1 |    86 |    86   (2)|
    |   1 |  SORT AGGREGATE                |                     |     1 |    86 |            |
    |   2 |   NESTED LOOPS OUTER           |                     |   898 | 77228 |    86   (2)|
    |   3 |    INLIST ITERATOR             |                     |       |       |            |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| ship_dtl            |   898 | 31430 |    85   (2)|
    |*  5 |      INDEX RANGE SCAN          | ship_dtl_IND_4      |  2876 |       |     1   (0)|
    |   6 |    TABLE ACCESS BY INDEX ROWID | INVN_SCOPE_DTL     |     1 |    51 |     2  (50)|
    PLAN_TABLE_OUTPUT
    |*  7 |     INDEX UNIQUE SCAN          | PK_INVN_SCOPE_DTL  |     1 |       |            |
    Predicate Information (identified by operation id):
       4 - filter("ship_dtl"."WHSE"='930' AND "ship_dtl"."STAT_CODE">=10 AND
                  "ship_dtl"."STAT_CODE"<=20)
       5 - access("ship_dtl"."OWNER_USER_ID"='*' OR "ship_dtl"."OWNER_USER_ID"='CTZDM')
       7 - access("INVN_SCOPE_DTL"."WHSE"(+)='930' AND
                  "INVN_SCOPE_DTL"."FROM_WORK_GRP"(+)='QC' AND "INVN_SCOPE_DTL"."FROM_WORK_AREA"(+)='MQN'
    PLAN_TABLE_OUTPUT
                  AND "ship_dtl"."START_CURR_WORK_GRP"="INVN_SCOPE_DTL"."TO_WORK_GRP"(+) AND
                  "ship_dtl"."START_CURR_WORK_AREA"="INVN_SCOPE_DTL"."TO_WORK_AREA"(+))
           filter("ship_dtl"."WHSE"="INVN_SCOPE_DTL"."WHSE"(+))
    25 rows selected.

    William Robertson wrote:
    I notice an OR predicate in the middle of some AND predicates without explicit bracketing. Are you sure it does what you think it does?I underline this point.
    A conjuction (AND expression) has a higher priority and will be executed (logically) before the disjunction (OR expression)! So your select looks like this
    SELECT COUNT(1)
    FROM INVN_SCOPE_DTL, ship_dtl
    WHERE
          ( ship_dtl.WHSE = INVN_SCOPE_DTL.WHSE (+)
          AND 'QC' = INVN_SCOPE_DTL.FROM_WORK_GRP (+)
          AND  'MQN' = INVN_SCOPE_DTL.FROM_WORK_AREA (+)
          AND  ship_dtl.START_CURR_WORK_GRP = INVN_SCOPE_DTL.TO_WORK_GRP (+)
          AND  ship_dtl.START_CURR_WORK_AREA = INVN_SCOPE_DTL.TO_WORK_AREA (+)
          AND  ship_dtl.WHSE = '930'
          AND  ship_dtl.OWNER_USER_ID = 'CTZDM'
    OR   ( ship_dtl.OWNER_USER_ID = '*'
          AND ship_dtl.STAT_CODE >= '10'
          AND ship_dtl.STAT_CODE <= '20'
    ;This might be want you want, but I doubt it very much. Please add parenthesis', to get it working the way it should be.
    Edited by: Sven W. on Oct 16, 2008 3:25 PM

  • Is there any way to rewrite this query?

    Is there room for improvement/rewrite for this query so that it performs well?
    select distinct shp_locn
      from shp_mstr
    where zone = to_char(:b3)
       and locn_class = 'r'
       and aisle = 'GX-08'
       and dock =  'KN'
       and locn_id not in (select locn_id from tmp_shp_out_dtl)
    order by shp_locn

    user659394 wrote:
    Alex,
    Stop your st_u_pi_d f_u_c__king sarcasm. There were lots of instances like the below thread
    where you bring your boring sarcasm to meaningful technical discussions.
    If you dont want to answer, just leave it..... you C__u__n__t
    Error for a SELECT COUNT ... in stored proc
    Alex was giving you perfectly valid assistance.
    Your post has now been reported to the moderators as it is completely offensive, unprofessional and unnecessary.

  • Is there any logical flaw in this query?

    DB version:10gR2
    Do you see any logical flaw, room for improvement in this query
    SELECT SHIP_QRY.RCVD_SHPMT_NBR, SHIP_QRY.ORIG_SHPMT_NBR, SHIP_QRY.DC_ORD_NBR, SHIP_QRY.WORK_ORD_NBR, SHIP_QRY.MFG_PLNT, SHIP_QRY.CONS_CASE_PRTY, SHIP_QRY.CONS_PRTY_DATE, SHIP_QRY.CONS_SEQ, SHIP_QRY.MFG_DATE, SHIP_QRY.RCVD_DATE, SHIP_QRY.XPIRE_DATE, SHIP_QRY.SHIP_BY_DATE, SHIP_QRY.PROC_IMMD_NEEDS, SHIP_QRY.VOL, SHIP_QRY.EST_WT, SHIP_QRY.ACTL_WT, SHIP_QRY.CASE_SIZE_TYPE, SHIP_QRY.PKG_NBR, SHIP_QRY.PKG_TYPE, SHIP_QRY.PO_NBR, SHIP_QRY.SHIP_VIA, SHIP_QRY.TRLR_NBR, SHIP_QRY.STAT_ID, SHIP_QRY.STAT_DATE_TIME, SHIP_QRY.VENDOR_CNTR_NBR, SHIP_QRY.PHYS_ENTITY_CODE, SHIP_QRY.PLT_ID, SHIP_QRY.TIER_QTY, SHIP_QRY.SNGL_pdt_CASE, SHIP_QRY.PUTWY_TYPE, SHIP_QRY.OUT_OF_ZONE_INDIC, SHIP_QRY.LAST_FROZN_DATE_TIME, SHIP_QRY.LAST_CNT_DATE_TIME, SHIP_QRY.SPL_INSTR_CODE_1, SHIP_QRY.SPL_INSTR_CODE_2, SHIP_QRY.SPL_INSTR_CODE_3, SHIP_QRY.SPL_INSTR_CODE_4, SHIP_QRY.SPL_INSTR_CODE_5, SHIP_QRY.MOD_DATE, SHIP_QRY.MOD_DATE_TIME, SHIP_QRY.USER_ID, SHIP_QRY.RETN_DISP_CODE, SHIP_QRY.FINAL_DISP_CODE, SHIP_QRY.INCUB_DATE, SHIP_QRY.SUPP_FTZ_CASE, SHIP_QRY.RCPT_IN_PROC_FLAG, SHIP_QRY.CD_MASTER_ID, SHIP_QRY.VENDOR_MASTER_ID, SHIP_QRY.VOCO_INTRNL_REVERSE_ID, SHIP_QRY.VOCO_INTRNL_REVERSE_PLT_ID, SHIP_QRY.CASE_NBR, SHIP_QRY.ship, SHIP_QRY.LOCN_ID, SHIP_QRY.PREV_LOCN_ID, SHIP_QRY.DEST_LOCN_ID FROM SHIP_QRY WHERE ( SHIP_QRY.CASE_NBR = :1 ) FOR UPDATE WAIT :"SYS_B_0"
    Edited by: user10583227 on Jan 13, 2009 7:05 PM

    How do you expect from us to find your logical flaw when we don't have any idea about your intention?
    Please post the details with some sample input data and your required output data along with brief explanation.
    Got me?
    Regards.
    Satyaki De.

  • Is there anyway  i could tune this query

    Post deleted due to flawed SQL
    Edited by: GarryB on Sep 22, 2008 4:54 AM

    You could try using subquery factoring for this part of your query:
    eg
    with UNITS_PAKS_sum as
    (SELECT sum(units_pakd) FROM carton_dtl WHERE carton_nbr = '00000999990000007527' AND sku_id = LMP_DEST.SKU_ID AND pkt_ctrl_nbr = '000000039')
    add units_paks_sum into your from list
    replace that sql with units_pakd (you have it in your columnlist and in your where clause.
    There will be a cartesian join, but since the "table" will only have 1 row its ok.
    Why are you using union rather than union all. If your two sections are guaranteed to be different use union all. Union is in fact union distinct. it does a sort operation to remove any duplicates. If you don't need to eliminate duplicates use union all

  • Is there anything that can be done to tune this query?

    DB version:10gR2
    From AWR report, we have determined that the following SQL is taking most CPU Time. Is there anything that we can do to improve the performance of this query.
    We have an index on (stat_code,create_date_time) columns of ext_replenish table.
    SELECT EXT_REPLENISH.EXT_REPLENISH_ID, EXT_REPLENISH.EVENT_ID, EXT_REPLENISH.EVENT_KEY, EXT_REPLENISH.WHSE, EXT_REPLENISH.VALIDATE_KEY, EXT_REPLENISH.NBR_OF_RETRY, EXT_REPLENISH.STAT_CODE, EXT_REPLENISH.ERROR_SEQ_NBR, EXT_REPLENISH.CREATE_DATE_TIME, EXT_REPLENISH.MOD_DATE_TIME, EXT_REPLENISH.USER_ID, EXT_REPLENISH.CL_MESSAGE_ID, EXT_REPLENISH.SCHEMA_ID, EXT_REPLENISH.ELS_ACTVTY_CODE, EXT_REPLENISH.CD_MASTER_ID FROM EXT_REPLENISH WHERE ( ( ( ( ( EXT_REPLENISH.STAT_CODE = :1 ) OR ( EXT_REPLENISH.STAT_CODE = :2 ) ) OR ( ( ( EXT_REPLENISH.STAT_CODE = :3 ) AND ( EXT_REPLENISH.ERROR_SEQ_NBR >= :4 ) ) AND ( EXT_REPLENISH.ERROR_SEQ_NBR < :5 ) ) ) AND ( EXT_REPLENISH.MOD_DATE_TIME <= :6 ) ) AND ( EXT_REPLENISH.NBR_OF_RETRY < :7 ) ) AND ROWNUM <= 1 ORDER BY EXT_REPLENISH.STAT_CODE ASC, EXT_REPLENISH.CREATE_DATE_TIME ASC FOR UPDATE
    Is there anyway i could tune this query?
    note: Ignore the unnecessary brackets. They are system created(apparently by hibernate)
    Message was edited by:
    Nichols
    Taking off the pre tags due to readability issue(all words appear in single line )
    Message was edited by:
    Nichols

    From just blindly looking at this particular query, there doesn't seem any obvious reason why an index couldn't be extended to cover all the columns specified in the where clause.
    It might not help too much -> explain plan is required first really before blindly guessing.
    Obviously, there's no point having an order by and a rownum (unless you wanted to do the order by before the rownum in an outer select) - I assume this is just a Hibernatism.

  • How to make this query more efficient

    Hi, i have query to find out the count of records based on certain conditions like below.
    SELECT count(*)
    FROM new_orders WHERE card_number IS NOT NULL
    AND exp_date IS NOT NULL
    AND card_id in ( select card_id from old_orders );
    There are millions of records in both the tables. , so it is taking long time to run. Is there any solution to optimize this query.....thanks for help. Bcj

    you might want to give this a try.
    SELECT count(*)
      FROM new_orders no
    WHERE no.card_number IS NOT NULL
       AND no.exp_date IS NOT NULL
       AND exists (select 'x'
                     from old_orders oo
                    where oo.card_id = no.card_id);it would also help if you can post the information needed as suggested by rob.

  • Is there a faster way to figure out what a negative number in base 8 is?

    Hi,
    Altough I know that using base 8 in java is rare, I am still curious about ways to convert from a negative decimal number into a base 8 number.
    For example, when we want to find out the negative representation of -11 (base 10) in base 8 . I would first convert -11 into the 2's complement representation of base 2 first (i.e. 11 in binary is 00001011; -11 two's complement is then 11110101). I then convert this into base 8 (365). Is there a faster way for this?
    I hope i am not confusing everybody.
    Thank you.
    - nygrl

    Octal values from 0 to Integer.MAX_VALUE is
    between 0 and 17777777777, and those from
    Integer.MAX_VALUE to -1 is from 20000000000 to
    37777777777.correction:
    Octal values from 0 to Integer.MAX_VALUE is between 0 and 17777777777, and those from Integer.MIN_VALUE to -1 is from 20000000000 to 37777777777.

  • Firefox prompts to enter master password while there is no form in the page

    I open Firefox and visit: http://twitter.com/astro_paolo
    Although there is no form in this page, Firefox prompts me to enter my master password

    Thanks cor-el, this was helpful !
    Twitter is not playing nice with Firefox master password feature. That's dumb, unsecure and serve no purpose at all. Twitter has bad programming issues.

  • How to improve the run time of this query

    Is there any way to improve this query,
    I have a table which SR_WId with atleast one subtype as 'Break Fix', 'Break/Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint'. then i can have other subtype as 'Break Fix', 'Break/Fix', 'Follow Up', 'Follw-Up','T&'||'M Break Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint'.
    Let me know if this is okay or to modify it.
    SELECT DISTINCT A.SR_WID AS SR_WID
    FROM WC_SR_ACT_SMRY_FS A
    WHERE EXISTS
    (SELECT NULL FROM WC_SR_ACT_SMRY_FS B
    WHERE B.ACT_TYPE = 'Maintenance'
    AND B.ACT_SUBTYPE in ('Break Fix', 'Break/Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint') AND B.NBR_OF_ACTIVITIES = 1 AND B.SR_WID = A.SR_WID
    GROUP BY B.SR_WID
    HAVING COUNT(B.SR_WID) >= 1)
    AND A.ACT_TYPE = 'Maintenance'
    AND A.ACT_SUBTYPE IN ('Break Fix', 'Break/Fix', 'Follow Up', 'Follw-Up','T&'||'M Break Fix','Break Fix/Corrective Maint','Break Fix-Corrective Maint')

    SELECT DISTINCT A.SR_WID AS SR_WID
               FROM WC_SR_ACT_SMRY_FS A
              WHERE EXISTS(
                       SELECT   NULL
                           FROM WC_SR_ACT_SMRY_FS B
                          WHERE B.ACT_TYPE = 'Maintenance'
                            AND B.ACT_SUBTYPE IN
                                  ('Break Fix',
                                   'Break/Fix',
                                   'Break Fix/Corrective Maint',
                                   'Break Fix-Corrective Maint')
                            AND B.NBR_OF_ACTIVITIES = 1
                            AND B.SR_WID = A.SR_WID
                       GROUP BY B.SR_WID
                         HAVING COUNT(B.SR_WID) >= 1 )
                AND A.ACT_TYPE = 'Maintenance'
                AND A.ACT_SUBTYPE IN
                      ('Break Fix',
                       'Break/Fix',
                       'Follow Up',
                       'Follw-Up',
                       'T&' || 'M Break Fix',
                       'Break Fix/Corrective Maint',
                       'Break Fix-Corrective Maint');First of all, you can omit the GROUP BY and HAVING part in the sub-select -
    we already know thath the only value for B.SR_WID can be A.SR_WID and
    COUNT(B.SR_WID) will always be at least 1, otherwise the sub-select will
    return nothing.
    As a second step, you could transform EXISTS() into IN():
    SELECT DISTINCT SR_WID
               FROM WC_SR_ACT_SMRY_FS A
              WHERE SR_WID IN(
                       SELECT B.SR_WID
                         FROM WC_SR_ACT_SMRY_FS B
                        WHERE B.ACT_TYPE = 'Maintenance'
                          AND B.ACT_SUBTYPE IN
                                ('Break Fix',
                                 'Break/Fix',
                                 'Break Fix/Corrective Maint',
                                 'Break Fix-Corrective Maint')
                          AND B.NBR_OF_ACTIVITIES = 1)
                AND ACT_TYPE = 'Maintenance'
                AND ACT_SUBTYPE IN
                      ('Break Fix',
                       'Break/Fix',
                       'Follow Up',
                       'Follw-Up',
                       'T&' || 'M Break Fix',
                       'Break Fix/Corrective Maint',
                       'Break Fix-Corrective Maint');

  • I have a ! next to some songs and i have to locate them under my music under my documents and when i do it plays in my itunes is there a faster way to do this?once i fix this can i do anything from it happening again?

    i have about 100 songs itunes shows a ! next to it says cannot find please locate i can locate them under my music under my documents and when i do it plays in itunesbut that would take a kong time is there a faster way to fix this?and once i do fix this is there a way for this not to happen again?

    Hello ryane84
    There really is not a faster way to link the songs. You could get the info on the missing songs to see where they sit on your computer and just move the files there before. Then you can organize your library to move them in the iTunes library folder or another place of your choosing. To keep it form happening again, the article does have a section on what to do to keep it organized when new media is added.
    iTunes: Finding lost media and downloads
    http://support.apple.com/kb/ts1408
    Regards,
    -Norm G.

  • How to make this query go faster

    Hi ,
    I have the following query :
    select a.* from
    tbl1 a , tbl2 b
    where a.id = b.id
    substr(b.id , 3, 2) <> 'XX'
    and b.date1 is not null
    and b.date1 >= sysdate - 90 ;
    tbl1 - 21 million rows
    tbl2 - 2 millions
    i specify this hints /*+ INDEX(idxa_1 , idxa_2) INDEX(ixdb_1)
    where idxa_1 --> b.lotid
    idxa_2 --> b.date1
    idxb_1 --> a.lotid
    IF i DO NOT include b.date1 is not null and b.date1 >= sysdate - 90 ,
    from explain plan i could see it using a FAST FULL SCAN which really returns very fast
    HOWEVER if i include b.date1 is not null and b.date1 >= sysdate - 90
    , from explain plain it uses row index and then there's a range scan and its slow
    how can i improve the performance of this query ?
    pls advise
    tks & rdgs

    Don't create the temporary table.
    Create a function based index on table two
    substr(id , 3, 2)Make sure you have gathered statistics on the tables.
    Remove the hint.
    select a.* from
    tbl1 a , tbl2 b
    where a.id = b.id
    and substr(b.id , 3, 2) <> 'XX'
    and b.date1 >= sysdate - 90;If you still have performance problems, post the formatted explain plan from sqlplus.
    Read the Performance Tuning Guide.
    Unfortunately this is not urs advice.

  • How can i make this query run for a form

    This query works fine for a sql report
    SELECT *
    FROM STUDENTS
    WHERE given_name||' '||family_name = :P101_USERNAME
    AND password = :P101_PASSWORD;
    But i want it to do the same thing for a form but i dont have the option like i do for the report where i can just apply the condition to the process.
    Anyone any ideas how i could do this so that when i go to the form this information is already there based on the username and password from the previous page?

    Assuming that page 101 is your login form, just lookup the primary key of the student based on the values presented in the login page fields, then set and pass this value to the form page.
    So you would create a process that runs near the very end of the the login processes on page 101, something like this:
    declare
    l_student_id students.student_id%TYPE;
    begin
    select student_id into l_student_id from students where  given_name||' '||family_name = :P101_USERNAME and password = :P101_PASSWORD;
    -- then set the value of your form page primary key field
    :P1_STUDENT_ID := l_student_id;
    end;I've done something similar and it works fine for me, although I haven't looked at it recently.
    Earl

  • Any way to materialize with fast refresh this query?

    I have three tables, A, B, C
    my query is:
    select
    from
    A
    inner join B on B.col=A.col
    left join C on C.b_id=B.id and C.a_id=A.id
    in essence, C is overriding a value from B in case it exists. I use this join often so I'd like to materialize it for performance reasons. The problem is, Mview requires traditional syntax (why is that??) which does not support joining C on two tables. Any way around this?
    Thanks

    Jernej Kase wrote:
    The problem is, Mview requires traditional syntax (why is that??) which does not support joining C on two tables. Any way around this?Hi Jernej,
    Your analysis is right. I don't know why MV's don't support ANSI join syntax, but I have encountered it before. Probably because when MV's where introduced, the ANSI join didn't exist in Oracle yet. But there is a way around this.
    First, reproducing your situation:
    SQL> create table a(id,col)
      2  as
      3  select 1, 'name 1' from dual union all
      4  select 2, 'name 2' from dual union all
      5  select 3, 'name 3' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table b (id,col)
      2  as
      3  select 1, 'name 1' from dual union all
      4  select 2, 'name 2' from dual union all
      5  select 3, 'name 3' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table c (a_id,b_id,col)
      2  as
      3  select 2, 2, 'name c2' from dual union all
      4  select 3, 3, 'name c3' from dual union all
      5  select 4, 4, 'name c4' from dual
      6  /
    Tabel is aangemaakt.
    SQL> alter table a add primary key (id)
      2  /
    Tabel is gewijzigd.
    SQL> alter table b add primary key (id)
      2  /
    Tabel is gewijzigd.
    SQL> alter table c add primary key (a_id,b_id)
      2  /
    Tabel is gewijzigd.
    SQL> select
      2  *
      3  from
      4  A
      5  inner join B on B.col=A.col
      6  left join C on C.b_id=B.id and C.a_id=A.id
      7  /
       ID COL       ID COL     A_ID  B_ID COL
        1 name 1     1 name 1
        2 name 2     2 name 2     2     2 name c2
        3 name 3     3 name 3     3     3 name c3
    3 rijen zijn geselecteerd.
    SQL> create materialized view log on a with rowid
      2  /
    Gematerialiseerde viewlog is aangemaakt.
    SQL> create materialized view log on b with rowid
      2  /
    Gematerialiseerde viewlog is aangemaakt.
    SQL> create materialized view log on c with rowid
      2  /
    Gematerialiseerde viewlog is aangemaakt.
    SQL> create materialized view abc_mv
      2    refresh fast on commit
      3  as
      4  select a.rowid a_rowid
      5       , b.rowid b_rowid
      6       , c.rowid c_rowid
      7       , a.id    a_id
      8       , b.id    b_id
      9       , a.col   a_col
    10       , b.col   b_col
    11       , c.col   c_col
    12    from A
    13         inner join B on B.col=A.col
    14         left join C on C.b_id=B.id and C.a_id=A.id
    15  /
           left join C on C.b_id=B.id and C.a_id=A.id
    FOUT in regel 14:
    .ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized viewTo circumvent this error message, the only option I see is to use nested MV's like this:
    SQL> create materialized view ab_mv
      2    refresh fast on commit
      3  as
      4  select a.rowid a_rowid
      5       , b.rowid b_rowid
      6       , a.id    a_id
      7       , b.id    b_id
      8       , a.col   a_col
      9       , b.col   b_col
    10    from a
    11       , b
    12   where a.col = b.col
    13  /
    Gematerialiseerde view is aangemaakt.
    SQL> create materialized view log on ab_mv with rowid
      2  /
    Gematerialiseerde viewlog is aangemaakt.
    SQL> create materialized view abc_mv
      2    refresh fast on commit
      3  as
      4  select ab.rowid ab_rowid
      5       , c.rowid  c_rowid
      6       , ab.a_id  a_id
      7       , ab.b_id  b_id
      8       , ab.a_col a_col
      9       , ab.b_col b_col
    10       , c.col    c_col
    11    from ab_mv ab
    12       , c
    13   where ab.a_id = c.a_id (+)
    14     and ab.b_id = c.b_id (+)
    15  /
    Gematerialiseerde view is aangemaakt.And to show that this works:
    SQL> select * from abc_mv
      2  /
    AB_ROWID           C_ROWID             A_ID  B_ID A_COL  B_COL  C_COL
    AAGpZ4AAQAAAS2sAAA                        1     1 name 1 name 1
    AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA     2     2 name 2 name 2 name c2
    AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB     3     3 name 3 name 3 name c3
    3 rijen zijn geselecteerd.
    SQL> update c set col = 'name c9' where a_id = 2
      2  /
    1 rij is bijgewerkt.
    SQL> commit
      2  /
    Commit is voltooid.
    SQL> select * from abc_mv
      2  /
    AB_ROWID           C_ROWID             A_ID  B_ID A_COL  B_COL  C_COL
    AAGpZ4AAQAAAS2sAAA                        1     1 name 1 name 1
    AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA     2     2 name 2 name 2 name c9
    AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB     3     3 name 3 name 3 name c3
    3 rijen zijn geselecteerd.
    SQL> insert into c values (1, 1, 'bla')
      2  /
    1 rij is aangemaakt.
    SQL> commit
      2  /
    Commit is voltooid.
    SQL> select * from abc_mv
      2  /
    AB_ROWID           C_ROWID             A_ID  B_ID A_COL  B_COL  C_COL
    AAGpZ4AAQAAAS2sAAA AAGpZxAAQAAAMrVAAA     1     1 name 1 name 1 bla
    AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA     2     2 name 2 name 2 name c9
    AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB     3     3 name 3 name 3 name c3
    3 rijen zijn geselecteerd.Regards,
    Rob.

Maybe you are looking for

  • Finder search in specific folder only - how to?

    I am a PC expert user switching to mac... I really like the mac, but the help needs to be greatly expanded. I am sure it is simple, but it is not intuitive, and help is worthless on this issue. In finder, I want to search a particular folder for a pa

  • Why are songs from certain iTunes playlists not syncing correctly on my iPhone 4S or iPad?

    Songs in my playlists within iTunes do not appear within the playlists on both my iPhone 4S or iPad when I sync these devices to my computer... Anyone have an idea for how to remedy this problem?

  • Message Bundle class not found

    Hello, i'm using JDev 10.1.3.3, and creating ADF BC application. When i've created the jspx page, went to it's Page Definition, and in Structure editor tried to add the Message Bundle file to this page - selected the "Generate Resource Bundle" from t

  • Thunderbird refuses to load my profile.

    Hello, For no obvious reason, TB 31.1.2 under Ubuntu 12.04 refuses to load my profile on startup. Instead, it invites me to create a new account. No folders or accounts are loaded. My ~/.thunderbird/profile.ini folder shows: [General] StartWithLastPr

  • No domain accessible to user logged in from BPEL Console

    I am unable to log in BPEL Console installed through SOA Suite 10.1.3.1.0. OC4Jadmin user integrated with OID. Unable to logged as oc4jadmin user to BPEL console or BPEL admin.