How to parallel subqueries combined by union all?

I has a view my_view whose definition is like
select * from tab_mod1@host1 union all
select * from tab_mod2 union all
select * from tab_mod3@host3 union all
select * from tab_mod4@host4 union all
select * from tab_mod5@host5 union all
select * from tab_mod6@host6
The query will run is like
select count(distinct col1) from my_view. I'd like all tables tab_modX could scan the table at the same time and send the data to the query coordinator. But if I used .
select /*+ parallel(a,4) */ count(distinct col1) from my_view a
The parallel is used only on the table sit in local host, and it seems oracle first get data from tab_mod1, and then get data from tab_mod2, etc, in serial.
Is it possible to run all the subqueries at the same time?
Thanks,
qihua

It is not possible to do what you want with PX.
You can submit a job for each subquery (job_queue_processes should be set into appropriate value to allow to execute several jobs at the same time), save result somewhere in table, wait for jobs to complete, and get final result.

Similar Messages

  • How can I join/Full outer join two different columns instead of union all?

    Hi,
    I have a scenario as the following:
    I am performing set operations using obiee 11g where I want to take values from two different criteria. Howwver, I dont want union to take place, instead i want join to take place to see all the columns in the output.
    For that, I tried changing the sql in advanced tab and tried to put full outer join instead of union all but its not allowing me to change.
    How can I achieve it? please help.
    Thanks.

    Hi,
    My problem is that I am unable to modify the sql in advanced tab. Probably due to some security reason,it's restricting me to change.
    Can you suggest me a way to change it?
    Thanks..

  • Drill down problem when using union all combination

    Hi All,
    I have a simple report with a drill down. The report has three columns Region, Sales, Flag... which will drill down to detail level of sales. The Flag column has Y, N values and we added 'All' Value in flag so that the user can select Y, N and All from the table prompt in the report . We have used union all in the report using combination to add the ' All ' Value in the flag. The problem is that now the main report is not passing the Flag values to the detail report. Flag is prompted in the filter in detail report.
    If I remove the 'All' value from Analysis with only Y N selection criteria the drill down works.
    Is there any work around? I have to use table prompt and All value selection in flag for drill down.
    Thanks,
    Virat

    The problem is without union all when doing combination of analysis drill down works, when I use combination drill down does not work because it does not pass the parameters for flag . I have used union all to add All value in flag.

  • How can we avoid union all in this query.....

    Dear All,
    I have a query which has union all.I want a query with the same result without using union all.Can anyone help me?Here is my query.............
    SELECT DID,
    DM.DISTRICT_DESCRIPTION "DISTRICT_NAME",
    MID,
    DM.DISTRICT_DESCRIPTION || '(D)' "MANDAL_NAME",
    200706,
    'SD_OB' "EXP_CAT",
    SUM(NVL(AMOUNT,0))-SUM(NVL(AMOUNT1,0)) "AMOUNT" FROM
    (SELECT SUBSTR(AC.PCC_INFO_CODE,3,2) "DID", SUBSTR(AC.TRANSACTION_ID,6,2) "MID",NVL(SUM(AMOUNT),0) "AMOUNT", 0 "AMOUNT1"
    FROM ACCTD_CLAIMS AC
    WHERE TO_CHAR(AC.CLAIM_DATE,'YYYYMM') <= PREV_MONTH(200706)
    AND AC.HOA_ID='18 '
    AND SUBSTR(AC.TRANSACTION_ID,1,3) <> 'CRR'
    GROUP BY SUBSTR(AC.PCC_INFO_CODE,3,2),SUBSTR(AC.TRANSACTION_ID,6,2)
    union all
    SELECT SUBSTR(AC.PCC_INFO_CODE,3,2) "DID", SUBSTR(AC.TRANSACTION_ID,6,2) "MID",0 "AMOUNT" , NVL(SUM(AMOUNT),0) "AMOUNT1"
    FROM ACCTD_CLAIMS AC
    WHERE
    TO_CHAR(AC.PAY_DATE,'YYYYMM') <= PREV_MONTH(200706)
    AND AC.HOA_ID='18'
    GROUP BY SUBSTR(AC.PCC_INFO_CODE,3,2), SUBSTR(AC.TRANSACTION_ID,6,2)), DISTRICT_MASTER DM
    WHERE DM.DISTRICT_ID=DID
    GROUP BY DID, MID, DM.DISTRICT_DESCRIPTION;
    Regards,
    Krishnadeep.

    <I want a query with the same result without using union all>
    You can write a pipelined function, which will be about ten times the work. Its best to use the simples tools; why don't you want to use UNION ALL since its probably the best answer?

  • Materialized Views Union ALL

    Sample SQL Query for Creating View
    CREATE MATERIALIZED VIEW TRIAL2
    PARALLEL 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    ENABLE QUERY REWRITE
    AS */
    select maa.INVENTORY_ITEM_ID,maa.ORGANIZATION_ID,maa.SR_INSTANCE_ID from msc_atp_rules ma,
              msc_atp_assignments maa
    where      maa.assignment_type = 3
    AND          maa.ATP_RULE_ID = ma.RULE_ID
    UNION ALL
    select maa.INVENTORY_ITEM_ID,maa.ORGANIZATION_ID,maa.SR_INSTANCE_ID from msc_atp_rules ma,
              msc_atp_assignments maa
    where      maa.assignment_type =3
    AND          maa.ATP_RULE_ID = ma.RULE_ID
    Test Syntax
    The SQL syntax is valid, however the query is invalid or uses functionality that is not supported.
    Declarative query support does not currently include UNION, INTERSECT or MINUS
    As a workaround, I created this view in the database and imported it onto jdev. This process worked totally fine. However, the Test Syntax still gives the same error, which means no modifications can be made on Jdev.
    Is my conclusion right, or am I missing some procedures that might get the UNIONs working?
    Thanks
    Rajiv

    Hi John,
    Thanks.
    How shall we create xdf then for such MV? Instead of xdf can we have sql script shipped.... or is there any other way of shipping such materialized view... In R12 and 11i (after 11.5.10) we used to ship corresponding xdf but in before 11.5.10 we used to ship sql scripts.

  • Union All vs. View Creation Problem

    Here is my problem basicly;
    I have three table.
    select * from table1;
    select * from table2;
    select * from table3;
    I need to create one view by combining those tables with 'union all' word.
    create or replace view view1 as
    select * from table1;
    union all
    select * from table2;
    union all
    select * from table3;
    Then, I want to write a query as;
    select * from view1 where column1 = x;
    When I did this, view1 first combines all the rows of the tables, then searches x value in all the data. That's OK. However I want to first search x value in the tables, and combine the results of each table and get the result rows.
    I mean, my query "select * from view1 where column1 = x;" need to act as
    select * from table1;
    column1 = x
    union all
    select * from table2;
    column1 = x
    union all
    select * from table3;
    column1 = x
    How can I do this?
    Thanks everyone..

    SnigRO
    I think what you mean is that your query is sequentially full scanning all three tables, and you would like instead for it to use index scans.
    Show the plan for the query. The predicate can be pushed down, but whether it makes any difference may depend:
    - statistics on each table (full scan may be faster than index scan)
    - are the various column1 columns indexed
    - certain documented or hidden optimiser parameters can encourage or discourage push down: eg optimizercost_based_transformation
    - Oracle version: there have been known bugs that interfere with push down (eg Bug 3723007 - Predicate push down may not occur in 10g - reported in 10.1)
    HTH
    Regards Nigel

  • Different results using View with union all in 11R1 compared to 10R2

    Hello,
    I have the following situation:
    In Oracle 10R2 I defined a view which looks like this
    create view test_view
    as
    select 'field1;field2;field3' field from dual
    union all
    select field
    from (
    select tfield1||';'||tfield2||';'||tfield3 field
    from table1
    order by tfield1,tfield2,tfield3
    The idea is, my first line contains a header information an then the data in the required sorting order.
    So, in 10R2, when I export the view with select field from test_view, I get the result as expected, which means, the header from the part with the dual was in the first line and after that, the data in the required sort order.
    Now, in 11.1.0.7, it is completely different, because the row of the dual is somewhere in my result set. But if I send the sql instead of the view, I get the expected result as in 10R2.
    I have no idea why this is the case now, because in 10R2 this was working permanently as expected. When I look at the execution plan, I see, that he starts parallelisation, which is ok, but the difference is, that in this parallelisation the select from dual is included and in 10R2 he first make the line from the dual and then the parallelisation with the data. It's not clear to me, that if I send the sql to the database I see the required result, but if i define the view as mentioned, and start a select field from view, I get now get the different sorting, because of the parallelisation, where the optimizer he changes his behavior comparing the both database versions. So my question ist, how can I change this behavior to get the same behavior as in release 10R2.
    Best regards
    Rainer

    Hello,
    thank you for your sample, I see your idea for my sorting purpose.
    I want to look at the following point:
    I create the table, as you described. The table has the degree and instances 1. Now I deefine the following view:
    create view view_test
    as
    select 'field1;field2;field3' field
    from dual
    union all
    select tfield1 || ';' || tfield2 || ';' || tfield3 field
    from (select * from table1 order by tfield1,tfield2).
    This is the way I used it in 10 R2.
    Now, the SQL select field from view_test delivers the expected result:
    field1;field2;field3
    a;b;c
    d;e;f
    So far so good. But now, I changed the degree of the table1 (alter table table1 parallel (degree 4 instances 1);).
    The result looks like that:
    a;b;c
    field1;field2;field3
    d;e;f
    So, the parallelisation of my object seems to be the reason for the, in my eyes, "wrong" sort order. In 10R2 I used this degree and instance values for my table and defined a view and it was working fine. Now, after our migration, I had this "trouble". For me it seems, that the optimizer made some changes, or mabe this is a bug, who knows ?
    I also tried, to change the nls_comp, and set the undocumented parameters as described in the Metalink note 7497640.8, but with no effect of my result set.
    Best regards
    Rainer

  • Concatenation and Union all

    Hi,
    From Oracle 9i performance guide:
    "Concatenation is useful for statements with different conditions combined with an OR clause"
    "If a query contains a WHERE clause with multiple conditions combined with OR operators, then the optimizer transforms it into an equivalent compound query that uses the UNION ALL set operator, if this makes the query execute more efficiently"
    Can anyone tell me when concatenation is better than union and vice versa?

    skde wrote:
    Hi,
    From Oracle 9i performance guide:
    "Concatenation is useful for statements with different conditions combined with an OR clause"
    "If a query contains a WHERE clause with multiple conditions combined with OR operators, then the optimizer transforms it into an equivalent compound query that uses the UNION ALL set operator, if this makes the query execute more efficiently"
    Can anyone tell me when concatenation is better than union and vice versa?Concatenation is not exactly the same as UNION ALL (the ALL is important, by the way), as it has to eliminate repetitions of data. You may rewrite an 'OR' query as a UNION ALL, concatenation is simply Oracle's strategy for doing this. There's an example on my blog which might help you understand the issues: http://jonathanlewis.wordpress.com/2007/02/26/subquery-with-or/
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
    +"I believe in evidence. I believe in observation, measurement, and reasoning, confirmed by independent observers. I'll believe anything, no matter how wild and ridiculous, if there is evidence for it. The wilder and more ridiculous something is, however, the firmer and more solid the evidence will have to be."+
    Isaac Asimov                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can we combine prompt values in Webintelligence Report(Combined Q:Union)

    Hi Every One,
    I had 4 Queries which are combined queries(Union).When i run the report ,displaying prompt values which are there in first Query.Can't we get combined prompt values when i run the report.I will explain with Scenario.
    Eg:
    Q1:Product level Country Information
    Prompt Values:Country(A,B,C,D,E,F,G,H)
    Q2:Component level Country Information
    Prompt Values:Country(A,B,C,D,E,F,L)
    Q3:Product level Source Information
    Prompt Values:Country(A,B,C,D,E)
    Q4:Product level Country Information
    Prompt Values:Country(A,B,C,D,E,F,M)
    When i run the report iam getting prompt values for country as (A,B,C,D,E,F,G,H)
    Could you help .
    Regards,
    Swapna.

    I'm having trouble understanding your scenario as you explain it.
    You are doing a union of the queries?
    So create query A, combine queries, union, create query B, etc.
    All of them use the same prompt message?
    So you either build the condition and reuse the same prompt message or you use a filter from the universe.
    In this case it is not possible to specify something different for each of the various subqueries.
    So you would have only one prompt answer, being whatever you answered to the prompt.
    If you have different prompt messages, you can give different answers, but then you have 4 prompt answers to display.
    It would be logical that only the first one is displayed if that is the one you display, you should display all four.
    If you just want to display the superset of countries which have been retrieved by the query you can put this information in a separate table block. If you make it a horizontal one, without borders, you should be able to come close to a normal prompt layout.
    Good luck,
    Marianne

  • Poblem with union/union all giving ORA-22950

    I am using a select statement with xmlelement to create an xml file.
    It has bout 5 different unions in it but I only ever bring one row through.
    I do it like this as then i can use this as one cursor in my plsql without having to create lots of cursors when i only need to use one.
    ie.
    SELECT  xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                          xmlelement(CUSTOMERNAME, customername),
                          xmlelement(QUOTE,quoteid )))xmlfile
    From cust, quote
    where custid=quotecustid
    and ptype = 'Q'
    UNION
    SELECT  xmlelement("SALES",xmlagg(xmlelement(SALES,
                          xmlelement(CUSTOMERNAME, customername),
                          xmlelement(QUOTE,salesid )))xmlfile
    From cust, sales
    where custid=salescustid
    and ptype = 'S'Then I use a cursor to run it to a ftp file the one record i have selected by passing in ptype as a parameter.
    if i use union i get ORA-22950 - i have seen other people say use UNION all to get round this.
    if i use union all i will get a value for SALES of no rows i.e.
    Any ideas how i can get round this as dont want to keep creating cursors

    Using different cursors is still the best approach IMO.
    All things considered, it should be more efficient than using only an appearing "smarter" one.
    And it doesn't need to be explicit cursors, it could just be SELECT INTOs wrapped in a PL/SQL CASE statement, with the proper exception handler (if necessary).
    Anyway, if you want to stick with the single-cursor method, there are different ways to do it :
    1) Adding a selector column :
    SELECT xmlfile
    FROM (
      SELECT 'Q' as selector
           , xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                      xmlelement(CUSTOMERNAME, customername),
                      xmlelement(QUOTE,quoteid )))xmlfile
      From cust, quote
      where custid=quotecustid
      and ptype = :1
      UNION ALL
      SELECT 'S'
           , xmlelement("SALES",xmlagg(xmlelement(SALES,
                      xmlelement(CUSTOMERNAME, customername),
                      xmlelement(QUOTE,salesid )))xmlfile
      From cust, sales
      where custid=salescustid
      and ptype = :1
    WHERE selector = :1
    ;2) Adding a GROUP BY clause, so that XMLAgg doesn't return anything if no rows are selected :
    SELECT xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                    xmlelement(CUSTOMERNAME, customername),
                    xmlelement(QUOTE,quoteid )))xmlfile
    From cust, quote
    where custid=quotecustid
    and ptype = :1
    GROUP BY null
    UNION ALL
    SELECT xmlelement("SALES",xmlagg(xmlelement(SALES,
                    xmlelement(CUSTOMERNAME, customername),
                    xmlelement(QUOTE,salesid )))xmlfile
    From cust, sales
    where custid=salescustid
    and ptype = :1
    GROUP BY null
    ;3) Subqueries :
    SELECT case :1
            when 'Q' then ( SELECT ... )
            when 'S' then ( SELECT ... )
          end as xmlfile
    FROM dual
    ;

  • Syntax Error - Using "Group By" with "Union All"

    Dear SAP community, I am a newb in need of help.
    Just spent the past 2 days searching for answers on how to build this query.
    Basically, I just want to group the Item Names (U_ItemName) together and have their respective quantities (U_Cart) added together so the same items display as one total quantity, no duplicates.
    I have tried so many combinations of GroupBy and Sum/Count....etc.  Nothing is working.
    The query:
    SELECT T1.[U_ItemName] AS 'Item Name', T1.[U_Cart] AS 'Cartons Available', T0.[Country] AS 'Country', T1.[U_ShlfLife] AS 'Shelf Life' FROM [dbo].[OWHS] T0 inner join [dbo].[@SICAS_EXT_WHS] T1  on T0.WhsCode=T1.U_WhseCode WHERE T0.[Country] = (N'JP' ) and DateDiff(Month, GetDate(),T1.[U_ShlfLife]) <= 6 union all
    SELECT T0.[U_ItemName], Sum(T0.[U_Cart]) as Cartons, T1.[Country], null FROM [dbo].[@SICAS_EXT_WHS]  T0, OWHS T1 WHERE T1.[Country] = (N'JP' ) and DateDiff(Month, GetDate(),T0.[U_ShlfLife]) >= 6
    GROUP BY T0.[U_ItemName], T0.[U_Cart], T1.[Country]
    Can anybody advise how to get this working?
    Thank you,
    Justice Nerenberg

    hi justice,
    I checked your code and it seems correct. but I don't have same table in database so i can't check it correctly.
    but I tried your problem with same situation and I am getting actual result.
    Example :-
    select itemcode,dscription,quantity from inv1
    where docdate>'2011-02-18 00:00:00.000'
    union all
    select itemcode,dscription,Sum(quantity) from inv1
    where docdate<'2011-02-18 00:00:00.000'
    group by itemcode,dscription
    Please do one thing rum both select queries separately whether running properly. Using above example you can check your code
    Thanks
    Annu

  • Union All is not bring the second part columns to the report

    I have 5 groups of series of Select statements and then I made a UNION ALL after the first group. Now it does run correctly and displays the output but it does not assign the second group' s field names.
    For example. I am greatly abridging
    Completed the SQL's needed to mimic a IBM i display screen. There are 5 product groups making up the screen. I was hoping to have one large Command SQL having the 5 SQLs using UNION ALL. This does 'compile' as a Command. However, it does only brings in the first part fields not the second. So this field is not included in the list of fields tree for COMMAND. PROGR2R2PST,
    Is there something not correct how doing the UNION ALL? OUTPUT assigns the column name
    of the first group to the second group. HLDGR1PUN 21454 87273
    so if i wanted to have one large SQL with union ALLs, it wont work. is there something other than UNION ALL I should use? One idea is if I can have 5 commands to my disposal. I guess  using subreports you can but it will be too slow.
    SELECT
    count(*) as PROGR1PST,
    SELECT COALESCE(SUM(OdQty#),0)
    FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTDTA.OEORD1
    WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND OHCOM# = ODCOM# AND OHORD# = ODORD#
    AND TSSTAT IN('AEP','BGE')
    AND OHORDT IN('RTR','INT','SAM')
    AND OHREQD < replace(char(current date, iso), '-', '')
    AND OHHLDC = ' '
    AND ODPRLC = 'ENG'
    AND substr(odprt#,1,5) <> 'NOENG' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a
    WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
    ) AS PROGR1PUN,
    SELECT count(*)
    FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTCCDTA.OETRA99
    WHERE OHCOM# = TSCOM# AND OHORD# = TSORD#
    AND (otCOM# = OHCOM# AND OTORD#= OHORD# AND ottrnc = 'AQC')
    AND TSSTAT IN('AEP','BGE')
    AND OHORDT IN('RTR','INT','SAM')
    AND OHREQD = replace(char(current date, iso), '-', '')  AND OHHLDC = ' ' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a
    WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
    ) AS PROGR1TOD,
    etc..
    UNION ALL
    SELECT
    count(*) as PROGR2R2PST,
    (SELECT COALESCE(SUM(OdQty#),0) FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTDTA.OEORD1
      WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND OHCOM# = ODCOM# AND OHORD# = ODORD#
      AND TSSTAT IN('AEP','BGE')
      AND OHORDT IN('CUS','CIN','SMC','COC','DON')
      AND OHREQD < replace(char(current date, iso), '-', '')
      AND OHHLDC = ' '
      AND ODPRLC = 'ENG'
      AND substr(odprt#,1,5) <> 'NOENG' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a 
    WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
    ) AS PROGR2PUN,

    hi Paul,
    a union combines record sets like this
    field1     field2
    1          2
    union
    field3     field4
    2          8
    will produce
    field1     field2
    1          2
    2          8
    note that there are no more field3 & field4 names. that's the way a union works.
    if you need separate fields for your other values then you would need to use sub-queries instead. to do that delete "UNION ALL " and create sub-queries with anything that is beneath that statement.

  • Materialized view - REFRESH FAST ON COMMIT - UNION ALL

    In a materialized view which uses REFRESH FAST ON COMMIT to update the data, how many UNION ALL can be used.
    I am asking this question because my materialized view works fine when there are only 2 SELECT statement (1 UNION ALL).
    Thank you.

    In a materialized view which uses REFRESH FAST ON COMMIT to update the data, how many UNION ALL can be used.As far as I remember you can have 64K UNIONized selects.
    I am asking this question because my materialized view works fine when there are only 2 SELECT statement (1 UNION ALL).Post SQL that does not work.

  • Updatable Materialized View with Union ALL

    (please don't ask about db structure)
    DB: 11gR2
    create table table_1  (
        id number primary key,
        val varchar2(100)
    create table table_2  (
        id number primary key,
        val varchar2(100)
    insert into table_1(id) values (0);
    insert into table_1(id) values (2);
    insert into table_1(id) values (3);
    insert into table_1(id) values (4);
    insert into table_1(id) values (5);
    insert into table_2(id) values (10);
    insert into table_2(id) values (12);
    insert into table_2(id) values (13);
    insert into table_2(id) values (14);
    insert into table_2(id) values (15);
    update table_1 set val='Table1 val:'||id;
    update table_2 set val='Table2 val:'||id;
    create view v_table_all as
    select * from table_1
    view V_TABLE_ALL created.
    select * from v_table_all;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             YES       YES        YES      
    VAL                            YES       YES        YES      
    update v_table_all set val='XXX changed' where id = 3;
    1 row updated.
    select * from table_1;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      XXX changed                                                                                         
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    rollback;
    select * from table_1;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    create or replace view v_table_all as
    select * from table_1
    union select * from table_2;
    view V_TABLE_ALL created.
    select * from v_table_all;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    10                     Table2 val:10                                                                                       
    12                     Table2 val:12                                                                                       
    13                     Table2 val:13                                                                                       
    14                     Table2 val:14                                                                                       
    15                     Table2 val:15  
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             NO        NO         NO       
    VAL                            NO        NO         NO       
    trying update:
    update v_table_all set val='XXX changed' where id = 3;
    SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
    01732. 00000 -  "data manipulation operation not legal on this view"
    *Cause:   
    *Action:
    drop view v_table_all;
    view V_TABLE_ALL dropped.all is ok before this point.
    now we want create a new materialized view with some query
    create  materialized view v_table_all
    as
    select * from table_1
    union all select * from table_2 ;
    materialized view V_TABLE_ALL created.
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             YES       YES        YES      
    VAL                            YES       YES        YES       it seems to be ok with update.
    but...
    update v_table_all set val='XXX changed' where id = 3;
    SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
    01732. 00000 -  "data manipulation operation not legal on this view"
    *Cause:   
    *Action:How can solve this issue??
    Any suggestion

    Looks like user_updatable_columns sort of thinks the MV is just a table - I don't know about that...
    An MV on a single table can be updated - I tried that and it works:
    create materialized view mv_table_1 for update
    as
    select * from table_1;I noticed [url http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/advmv.htm#sthref294]examples stating the UNION ALL needs a "marker" so Oracle can know from the data which source table a row in the MV originates from - like this:
    create materialized view v_table_all for update
    as
    select 'T1' tab_id, table_1.* from table_1
    union all
    select 'T2' tab_id, table_2.* from table_2 ;But that also fails (the "marker" requirement was specifically for FAST REFRESH, so it was just a long shot ;-) )
    What are you planning to do?
    <li>Create the MV.
    <li>Update records in the MV - which then is no longer consistent with the source data.
    <li>Schedule a complete refresh once in a while - thereby overwriting/losing the updates in the MV.
    If that is the case, I suggest using a true table rather than an MV.
    <li>Create table t_table_all as select ... .
    <li>Update records in the table - which then is no longer consistent with the source data.
    <li>Schedule a job to delete table and insert into table select ... once in a while - thereby overwriting/losing the updates in the table.
    In other words a kind of "do it yourself MV".
    I cannot see another way at the moment? But perhaps try in the data warehousing forum - the people there may have greater experience with MV's ;-)

  • Re Creating  a chart getting an error with a 'Union All' statement

    Hi
    I have some data to chart with the following fields;
    Product , Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10.
    The PRODUCT field is text showing the numerous Product Names
    The Jul-08 & other month fields have numbers per product that is to be aggregated for that month & plotted on the line graph.
    My SQL to create the first point on the chart is as below;
    select null link, PRODUCT label, SUM(JUL-08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    GROUP by PRODUCT
    ORDER BY PRODUCT
    This works fine until I want add the second point of this line graph using a 'union all' join as follows;
    select null link, PRODUCT label, SUM(JUL_08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    UNION ALL
    select null link, PRODUCT label, SUM(AUG_08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    I can't work out how I can join the other months on the line graph in one series.
    The error is as follows;
    1 error has occurred
    Failed to parse SQL query:
    select null link, PRODUCT label, SUM(OCT_09) "NCDS - STD" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - STD' UNION ALL select null link, PRODUCT label, SUM(NOV_09) "NCDS - LOCAL" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - LOCAL'
    ORA-00937: not a single-group group function
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Can anyone assist?
    I want a continuous Line Graph that shows all the months from Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10 for the same product.
    I will then add other series for the other products, Thanks

    OK, I thought each month would be separated by the different months in each selct subquery, but I see what you mean.
    I'm creating a line graph for various PRODUCTS that has a numeric value for each month, from JUL_08 ..... for a number of months.
    I want a LINE graph that shows the different totals each month for that PRODUCT.
    The error advises that there are more values in the SELECT statement than the expected and to use Use the following syntax:
    SELECT LINK, LABEL, VALUE
    FROM ...
    I then went on to use the '[ ]' brackets to separate data but this didn't fix the problem.
    I've changed the script to suit as per your 'PERIOD' addition but now have the error as per below;
    error script
    1 error has occurred
    Invalid chart query: SELECT null link, PRODUCT label, PERIOD, SUM(ABC) FROM (SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT) GROUP BY link, PRODUCT, PERIOD
    Use the following syntax:
    SELECT LINK, LABEL, VALUE
    FROM ...
    Or use the following syntax for a query returning multiple series:
    SELECT LINK, LABEL, VALUE1 [, VALUE2 [, VALUE3...]]
    FROM ...
    LINK URL
    LABEL Text that displays along a chart axis.
    VALUE1, VALUE2, VALUE3... Numeric columns that define the data values.
    Note: The series names for Column and Line charts are derived from the column aliases used in the query.
    My script amended;
    SELECT null link, PRODUCT label, PERIOD, SUM(ABC)
    FROM
    (SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT
    UNION ALL
    SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT
    UNION ALL
    SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT)
    GROUP BY link, PRODUCT, PERIOD

Maybe you are looking for

  • Lock up, BSOD, freezing, ad infinitum.

    Compaq SR5333WM Desktop Windows 7 (almost installed) last known error: STOP: Error 0x000008e No changes made before the error. tried to reinstall windows, failed. got a new hard drive and tried to install windows, failed. memtest checks out ok. canno

  • SLT with MDC

    Hello experts, Is SLT working with MDC? If it is, how does SLT connect to the each tenant DB for data replication where there is one system DB? Please advise. Thanks.

  • Ical stopped syncing to treo 650 and other quirks

    I have been using ical with the palm software on my treo 650, but now updates to my calendar aren't syncing. I don't know of any changes that I've made, and I think I have checked all of the settings. I don't know if this is related, but a couple of

  • Uninstall older versions

    After intallation of Photoshop CS6, can I uninstall previous versions of Photoshop?

  • Frames in iWeb?

    I would like to have an iCal that I have published on .mac appear in my website that I have created with iWeb. Outside of iWeb I would have this done with frames but I'm not sure how I would do this with iWeb. Any help would be appreciated. sb