Inconsistent SQL results when using View with UNION-ALL and table function

Can any of you please execute the below scripts and check the output. In the table type variable, I am adding 4 distinct object ids, where as in the result, I get only the row pertaining to last id in the table type variable. Same row is returned 4 times (4= number of values in the table type).
This scenario is occurring in our product with a SQL with exactly same pattern. I could simulate the same issue with the sample script I have provided.
Database version: 11.2.0.3 Enterprise Edition, Single node
Thank you.
CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
CREATE OR REPLACE VIEW TEMP_T1T2_V AS
SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER);
CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE;
SET SERVEROUTPUT ON;
DECLARE
TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
BEGIN
TEMP_OBJ_TAB.EXTEND;
TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
END;
BEGIN
ADD_TO_TEMP_OBJ_TAB(100);
ADD_TO_TEMP_OBJ_TAB(116);
ADD_TO_TEMP_OBJ_TAB(279);
ADD_TO_TEMP_OBJ_TAB(364);
DBMS_OUTPUT.PUT_LINE('=====================');
FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
END LOOP;
DBMS_OUTPUT.PUT_LINE('---------------------');
SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
FROM TEMP_T1T2_V VW
WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
END LOOP;
DBMS_OUTPUT.PUT_LINE('---------------------');
IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
END LOOP;
ELSE
DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
END IF;
DBMS_OUTPUT.PUT_LINE('---------------------');
END;
/

I can reproduce it:
SQL*Plus: Release 11.2.0.3.0 Production on Tue Oct 30 14:05:39 2012
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter user-name: scott
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select  *
  2    from  v$version
  3  /
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
Table created.
SQL>
SQL> CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
Table created.
SQL>
SQL> UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
72883 rows updated.
SQL>
SQL> CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
Index created.
SQL>
SQL> CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
Index created.
SQL>
SQL> CREATE OR REPLACE VIEW TEMP_T1T2_V AS
  2  SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
View created.
SQL>
SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER)
  2  /
Type created.
SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE
  2  /
Type created.
SQL> SET SERVEROUTPUT ON;
SQL>
SQL> DECLARE
  2  TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
  3  TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
  4  TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
  5  PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
  6  BEGIN
  7  TEMP_OBJ_TAB.EXTEND;
  8  TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
  9  END;
10  BEGIN
11  ADD_TO_TEMP_OBJ_TAB(100);
12  ADD_TO_TEMP_OBJ_TAB(116);
13  ADD_TO_TEMP_OBJ_TAB(279);
14  ADD_TO_TEMP_OBJ_TAB(364);
15  DBMS_OUTPUT.PUT_LINE('=====================');
16  FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
17  LOOP
18  DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
19  END LOOP;
20  DBMS_OUTPUT.PUT_LINE('---------------------');
21  SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
22  FROM TEMP_T1T2_V VW
23  WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
24  FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
25  FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
26  LOOP
27  DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
28  END LOOP;
29  DBMS_OUTPUT.PUT_LINE('---------------------');
30  IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
31  FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
32  LOOP
33  DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
34  END LOOP;
35  ELSE
36  DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
37  END IF;
38  DBMS_OUTPUT.PUT_LINE('---------------------');
39  END;
40  /
=====================
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
364 : I_AUDIT
364 : I_AUDIT
364 : I_AUDIT
364 : I_AUDIT
PL/SQL procedure successfully completed.
SQL> column object_name format a30
SQL> select  object_id,
  2          object_name
  3    from  dba_objects
  4    where object_id in (100,116,279,364)
  5  /
OBJECT_ID OBJECT_NAME
       100 ORA$BASE
       116 DUAL
       279 MAP_OBJECT
       364 I_AUDIT
SQL>  Works fine in:
=====================
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
100 : ORA$BASE
116 : DUAL
364 : SYSTEM_PRIVILEGE_MAP
279 : MAP_OBJECT
PL/SQL procedure successfully completed.
SQL> select  object_id,
  2          object_name
  3    from  dba_objects
  4    where object_id in (100,116,279,364)
  5  /
OBJECT_ID OBJECT_NAME
      100 ORA$BASE
      116 DUAL
      364 SYSTEM_PRIVILEGE_MAP
      279 MAP_OBJECT
SQL> select  *
  2    from  v$version
  3  /
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>SY.
Edited by: Solomon Yakobson on Oct 30, 2012 2:14 PM

Similar Messages

  • Materalized view with union all and fast referesh

    I have a one view which is very slow. in this view we are joining many tables and many union all queries.
    now I am planing to make materalized view
    Tell me how i will created view with fast refresh with union all query.
    Pls help its urgent..
    Thanks
    Reena

    Refer to the Replication Manual for the create syntax and exceptions.

  • 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

  • Oracle doc inconsistent on materialize view with union all and self joins

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

  • Report which concatenates 13 views with union all running slowly

    Oracle 8.1.7 windows 2000 server
    I am trying to improve the performance of a report which is comprised of 13 views.
    When I run each of the views individually, the total run time for the views is less than 5 minutes. When I run the report, it takes 28 minutes.
    Can anyone suggest why the extra time is being taken?
    To reiterate:
    select a,b from c; (executes in 10 seconds)
    select d, e from f (executes in 3 seconds)
    select x, y from z (executes in 1 minute)
    total runs time = 5 minutes
    However,
    select a,b from c
    union all
    select d, e from f
    union all
    select x, y from z (executes in 28 minutes)
    The execution plans do not change between the report and the indiividual views. Views are being concatenated with union all so no sorting is taking place
    Many thanks,
    Jason Parker.
    Edited by: jclparker on Feb 18, 2009 4:26 AM
    Edited by: jclparker on Feb 18, 2009 4:30 AM

    Could you post the execution plan? Please use formatting tags to save the white space while posting the plan.

  • Inconsistent results when using queries with UDF

    I have the following query that I can not get consistent results. Sometimes it will get the correct result but at other times it does not. I can not figure out what I am doing wrong.
    The scenario is I have on the BP Contact several UDF that we are storing sales territory information. We want to pull based on the SalesRepNo the RegName. We have 2 user defined tables set up. I can accurately pull info when I am linking to the SLS_Person_Region table. On that table there is a field called region (a number). I am trying to use that number and pull the name from the Region_Major_reg table.
    SELECT T0.[U_RegName] FROM [dbo].[@REGION_MAJOR_REG]  T0 INNER JOIN  [dbo].[@SLS_PERSON_REGION]  T1 ON T1.U_Region = T0.U_Region INNER JOIN ocpr T2 on T1.[U_SlsPerNum] = T2.[U_SalesRepNo]
    WHERE  T1.U_SlsPerNum = $[OCpr.U_SalesRepno]
    What is frustrating is that the query works fine for different terrioties.
    Any help would be appreciated.
    Thanks
    Steve

    the scheme is the first tow indicate the territory
    The next two digits represent the rep
    When a rep is replaced we assign an open territory or the next rep the next number
    an example is 0105 was an open territory when we signed a new rep we gave them 0106
    To answer your question we have nine
    0106
    0205
    0303
    0401
    0503
    0602
    0702
    0801
    0904
    I think that is what you are asking

  • Discoverer 4i Plus returns no data when using views with db link references

    I am using Discoverer 41 Plus to view reports online.
    When I create a worksheet based on a view, that only references local tables, everything is OK and Disco plus shows the output OK.
    When I create a worksheet based on a view, that references a Database link, Disco plus gives me an "Query caused no data to be returned" error.
    Is this to be expected from Discoverer Plus?
    Thanks - Sue.

    I'm wondering if this has anything to do with the default position (and default aggregate) for the EUL folder item? I can see that some of the folders have number type items with default position 'Data Point' and others have these with default position of 'Top or Side'. I'm totally stabbing around in the dark here; looking at EUL folders which exhibit the problem and those which don't.
    I've tried changing one field to 'Data Point' and it hasn't helped. Will try changing the join items now I think.
    If anyone has any comments, would be v. grateful as I'm looking at dropping folders which have quite a bit of code around them and trying to re-create them exactly, which is a risky and horrible solution.

  • 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 ;-)

  • Error creating materilalized view with union all

    Could please anybody advice? What I do wrong?
    create table test
    i number not null,
    constraint pk_test primary key( i ));
    create materialized view log on test with rowid;
    create materialized view mvtest refresh fast on demand as
    SELECT i, 1 umarker FROM test where i < 10000
    UNION ALL SELECT i, 2 umarker FROM test where i > 10000;
    ORA-12052: cannot fast refresh materialized view MVTEST
    It looks like I accomplished all fast refresh requirements, didn't I?
    Thanks a lot.
    Alexander.

    SQL> create table test
      2  (i number not null,
      3  constraint pk_test primary key( i ));
    Table created.
    SQL> create materialized view log on test with rowid;
    Materialized view log created.
    SQL> create materialized view mvtest refresh fast on demand as
      2  SELECT t.i, 1 umarker, t.rowid row_id FROM test t where t.i <= 10000
      3  UNION ALL
      4  SELECT t.i, 2 umarker, t.rowid row_id FROM test t where t.i > 10000;
    Materialized view created.(This is on 11.2)

  • My up and down arrows as well as page up and page down no longer work properly only when using firefox. Page up and down function more like the "home" and "end" keys as do the arrow keys.

    Honestly I'm not sure if these began just after I updated FF to the current release, but it's been happening for at least 2 weeks. The arrow keys and page up and page down keys all work as if I'm pressing the 'home' and 'end' keys on my keyboard. This is only when using FF. Please contact me if you need more clarification. Thanks in advance!

    Sounds that you have switched on caret browsing.
    * http://kb.mozillazine.org/accessibility.browsewithcaret
    You can press press F7 (on Mac: fn + F7) to toggle caret browsing on/off.
    * Tools > Options > Advanced : General: Accessibility: [ ] "Always use the cursor keys to navigate within pages"
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox

  • ORA13226 when using view with geometry created using sdo_util.simplify

    I have a polygon table (and spatial index) using Ora11.1 that i can query such as:
    Select ID From MyTable A where (MDSYS.SDO_RELATE(A.GEOMETRY, SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARRAY(73.091805, 18.312310, 72.250051, 19.076872)), 'mask=INSIDE+COVEREDBY+EQUAL querytype=window') = 'TRUE');
    This query returns 2 rows. I have created a view:
    create or replace view v_MyTable as
    select id, sdo_util.simplify(geometry,20,2) as s_geometry
    from MyTable;
    The subsequent query returns ORA13226
    Select ID From v_MyTable A where (MDSYS.SDO_RELATE(A.S_GEOMETRY, SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARRAY(73.091805, 18.312310, 72.250051, 19.076872)), 'mask=INSIDE+COVEREDBY+EQUAL querytype=window') = 'TRUE');
    If I create a view which does not use the simplify function the query works.

    tcbalent,
    This is correct behaviour if you are trying the query the view:
    Select ID
      From V_MyTable A
    where (MDSYS.SDO_RELATE(A.GEOMETRY, SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARRAY(73.091805, 18.312310, 72.250051, 19.076872)), 'mask=INSIDE+COVEREDBY+EQUAL querytype=window') = 'TRUE');This is because the A.GEOMETRY is not the geometry in the original table (MyTable) but a programmatically
    constructed geometry on the fly which is not indexed.
    You can fix this with a function based index as follows (NOTE: This uses my own test data that is projected and not geodetic):
    DROP  table myTable;
    create table myTable
    as
    select rownum as Id, geom as geometry
    from  projpoly2d
    where polytype NOT IN ('COMPOUNDOUTERSHELL','VERTEXWITHARCNOHOLE');
    delete from user_sdo_geom_metadata where table_name = 'MYTABLE' and column_name = 'GEOMETRY'; commit;
    insert into user_sdo_geom_metadata(table_name, column_name,diminfo,srid)
    select 'MYTABLE','GEOMETRY',diminfo,srid
      from user_sdo_geom_metadata
    where table_name = 'PROJPOLY2D'
       and column_name = 'GEOM';
    commit;
    create or replace view v_MyTable
    as
    select id, sdo_util.simplify(geometry,20,2) as S_geometry
    from MyTable;
    -- Create index metadata
    delete from user_sdo_geom_metadata where table_name = 'MYTABLE' and column_name = 'MDSYS.SDO_UTIL.SIMPLIFY(GEOMETRY,20,2)'; commit;
    insert into user_sdo_geom_metadata(table_name, column_name,diminfo,srid)
    select 'MYTABLE','MDSYS.SDO_UTIL.SIMPLIFY(GEOMETRY,20,2)',diminfo,srid
      from user_sdo_geom_metadata
    where table_name = 'MYTABLE' and column_name = 'GEOMETRY';
    commit;
    select * from user_sdo_geom_metadata;
    -- Now create index
    drop   index MyTable_sgeometry_spdx;
    create index MyTable_sgeometry_spdx on MyTable(MDSYS.SDO_UTIL.SIMPLIFY(GEOMETRY,20,2))
         indextype is mdsys.spatial_index parameters('sdo_indx_dims=2, layer_gtype=polygon');
    Select ID
      From v_MyTable A
    where (MDSYS.SDO_RELATE(A.S_GEOMETRY,
                             MDSYS.SDO_GEOMETRY(2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3), MDSYS.SDO_ORDINATE_ARRAY(190000.0, 5120000.0, 640000.0, 5630000.0)),
                            'mask=INSIDE+COVEREDBY+EQUAL querytype=window') = 'TRUE');
    -- Result
    ID                    
    5                     
    1                     
    4                     
    2                     
    6If this fixes your problem please mark this thread as answered.
    regards
    Simon

  • Using union all and rownum

    Hello again.
    Another question.
    Can I query with union all and stop it when I get N rows.
    For example:
    select 1 from dba_segments
    union all
    select 2 from dba_segments where
    union all
    select 3 from dba_segments where;
    and get the 100 first rows without doing the whole query:(not like that-->)
    select * from (
    select 1 from dba_segments
    union all
    select 2 from dba_segments where
    union all
    select 3 from dba_segments where)
    where rownum < 100);
    I want the query will stop when there are 100 rows in the result set.
    thank you!

    You already posted your own answer. It just seems you don't want to use it.
    ROWNUM is NOT assigned until the rows are selected to be returned. So you need to wrap the three inner queries into a query that uses ROWNUM.

  • Incorrect Results When Using an In-Line View and User Function in 10g

    My developers are complaining of incorrect Select statement results when using an in-line view along with a user defined function. Below is the statement:
    select test_f(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    Test_f() is a user defined function and the above query returns thousands of rows. It should return 308 rows. It is apparent that the target database is not evaluating the "where wo1 is null;" clause.
    select to_char(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    In the above query return 308 rows. The user function was replaced by an Oracle function. The Where clause is now evaluated correctly.
    The query is executed from an Oracle 10g R2 database and retrieves data from a 9.2.0.6 database.
    I've seen a little information on Metalink. It appears that there was some trouble in 9i, but were fixed in a 9.2.0.6 patch. I don't see any information about a 10.2.0.2 database.
    Anyone have any experiences or a successful solution. I suspect that I will need to report this to Oracle and wait for a patch.
    Thanks,
    John

    I can only think of two reasons for this behaviour:
    1) You are executing these two queries from two different users and there is some policy on the table.
    2) The function doesn't do an upper, but returns null a lot of times, even when the input is a not null value, like this:
    SQL> create table tidwowrk
      2  as
      3  select 1 id, 'A' work_order_nbr, 'DST' facility from dual union all
      4  select 2, null, 'TRN' from dual union all
      5  select 3, 'C', 'DST' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table tidwotsk
      2  as
      3  select 'A' work_order_nbr from dual union all
      4  select 'B' from dual
      5  /
    Tabel is aangemaakt.
    SQL> create or replace function test_f (a in varchar2) return varchar2
      2  is
      3  begin
      4    return case a when 'A' then null else a end;
      5  end;
      6  /
    Functie is aangemaakt.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , test_f(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A
      5                , TIDWOTSK B
      6            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      7              and a.facility in ('DST', 'TRN', 'SUB')
      8         )
      9   where wo1 is null
    10  /
                                  COUNT(*)
                                         3
    1 rij is geselecteerd.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , to_char(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A, TIDWOTSK B
      5            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      6              and a.facility in ('DST', 'TRN', 'SUB')
      7         )
      8   where wo1 is null
      9  /
                                  COUNT(*)
                                         2
    1 rij is geselecteerd.Regards,
    Rob.

  • Using SCORE on top of View with UNION

    Hi guys,
    I explain what I'm trying to do quickly:
    2 Tables: table1 and table2 with same structure and both have a multi_column_datastore ctxsys.context.
    1 View: view1
    select * from table1
    union
    select * from table2
    if I run:
    select * from view1 WHERE contains(view1.COLUMN1,'%textext%',1 ) > 0;
    this works fine, I get the correct result.
    If I try to use SCORE function I have an error:
    select * from view1 WHERE contains(view1.COLUMN1,'%textext%',1 ) > 0 ORDER by SCORE(1);
    ORA-29921: Ancillary operator not supported with set view query block
    I understand the problem is in the UNION inside the view,is there any way to make it works keep filtering the VIEW?
    Thanks in advance

    There is no score in the view, so you can't reference the score when querying the view.  In order to put the score in the view, you need a contains clause, which requires a value.  One method of doing this is to use sys_context.  Please see the reproduction of the problem and solution below.
    SCOTT@orcl12c> -- reproduction of problem:
    SCOTT@orcl12c> create table table1
      2    (column1  varchar2(30))
      3  /
    Table created.
    SCOTT@orcl12c> insert into table1 values ('textext')
      2  /
    1 row created.
    SCOTT@orcl12c> create table table2
      2    (column1 varchar2(30))
      3  /
    Table created.
    SCOTT@orcl12c> insert into table2 values ('textext')
      2  /
    1 row created.
    SCOTT@orcl12c> begin
      2    ctx_ddl.create_preference ('test_ds', 'multi_column_datastore');
      3    ctx_ddl.set_attribute ('test_ds', 'columns', 'column1');
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> create index table1_idx on table1 (column1)
      2  indextype is ctxsys.context
      3  parameters ('datastore  test_ds')
      4  /
    Index created.
    SCOTT@orcl12c> create index table2_idx on table2 (column1)
      2  indextype is ctxsys.context
      3  parameters ('datastore  test_ds')
      4  /
    Index created.
    SCOTT@orcl12c> create or replace view view1
      2  as
      3  select * from table1
      4  union
      5  select * from table2
      6  /
    View created.
    SCOTT@orcl12c> select * from view1 where contains (view1.column1, '%textext%', 1) > 0
      2  /
    COLUMN1
    textext
    1 row selected.
    SCOTT@orcl12c> select * from view1 where contains (view1.column1,'%textext%',1 ) > 0 order by score(1)
      2  /
    select * from view1 where contains (view1.column1,'%textext%',1 ) > 0 order by score(1)
    ERROR at line 1:
    ORA-29921: Ancillary operator not supported with set view query block
    SCOTT@orcl12c> -- solution:
    SCOTT@orcl12c> create or replace view view1
      2  as
      3  select score(1) score, table1.* from table1
      4  where  contains (table1.column1, sys_context ('text_query', 'query_value'), 1) > 0
      5  union
      6  select score(1) score, table2.* from table2
      7  where  contains (table2.column1, sys_context ('text_query', 'query_value'), 1) > 0
      8  /
    View created.
    SCOTT@orcl12c> create or replace context text_query using text_proc
      2  /
    Context created.
    SCOTT@orcl12c> create or replace procedure text_proc
      2    (p_val in varchar2)
      3  as
      4  begin
      5    dbms_session.set_context ('text_query', 'query_value', p_val);
      6  end text_proc;
      7  /
    Procedure created.
    SCOTT@orcl12c> exec text_proc ('%textext%')
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> set autotrace on explain
    SCOTT@orcl12c> select * from view1 order  by score
      2  /
         SCORE COLUMN1
             3 textext
    1 row selected.
    Execution Plan
    Plan hash value: 4090246122
    | Id  | Operation                       | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |            |     2 |    60 |     8   (0)| 00:00:01 |
    |   1 |  SORT ORDER BY                  |            |     2 |    60 |     8   (0)| 00:00:01 |
    |   2 |   VIEW                          | VIEW1      |     2 |    60 |     8   (0)| 00:00:01 |
    |   3 |    SORT UNIQUE                  |            |     2 |    58 |     8  (50)| 00:00:01 |
    |   4 |     UNION-ALL                   |            |       |       |            |          |
    |   5 |      TABLE ACCESS BY INDEX ROWID| TABLE1     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  6 |       DOMAIN INDEX              | TABLE1_IDX |       |       |     4   (0)| 00:00:01 |
    |   7 |      TABLE ACCESS BY INDEX ROWID| TABLE2     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  8 |       DOMAIN INDEX              | TABLE2_IDX |       |       |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       6 - access("CTXSYS"."CONTAINS"("TABLE1"."COLUMN1",SYS_CONTEXT('text_query','query_v
                  alue'),1)>0)
       8 - access("CTXSYS"."CONTAINS"("TABLE2"."COLUMN1",SYS_CONTEXT('text_query','query_v
                  alue'),1)>0)
    Note
       - dynamic statistics used: dynamic sampling (level=2)
    SCOTT@orcl12c>

  • Hello! I'm using Aperture with Efex plugins and notice, what when I saving result in plugin and go back to aperture, preview mode is going to grey color and not working until I reboot Aperture. Did you saw this problem?

    Hello! I'm using Aperture with Efex plugins and notice, what when I saving result in plugin and go back to aperture, preview mode is going to grey color and not working until I reboot Aperture. What is intresting - in full screen mode everything works fine. Did you saw this problem?

    It seems there's a workaround here:
    https://discussions.apple.com/thread/5566037?tstart=0

Maybe you are looking for

  • Missing text after EXPORT from PMD to PDF

    Hi, I have a document, designed through Adobe pagemaker 70, which I would like converted to PDF. Within Adobe PageMaker 70 I performed a File-->Export-->Adobe PDF, kept all the default options and managed to generate a PDF version of the *.PMD docume

  • How to return sdo_geometry from java procedure

    How can I return a SDO_GEOMETRY object from a java-stored-procedure to PL/SQL. I have a java class with methods that creates a specific polygon based on some user values. I want to return this polygon as a SDO_GEOMETRY object to a PL/SQL procedure. J

  • UserProfile Thumbnail photos appear to be syncing, but not Appearing in SharePoint 2013 (MySites)

    Hi community I might have stumbled on some issue with a corrupt Photo store.  Last week, I ran a scripted update to the client's AD where I updated the thumbnailPhoto  and some custom attributes.  The result has been HR have been inundated with reque

  • Copy&paste from a file excel to Adobe Interactive Form

    Hi all my project is based on WDJ and Adobe Interactive Form. I need to know if it is possible to do a copy&paste from a file excel to my Adobe Interactive Form. Can I copy an area of data from an Excel spreadsheet (set of contiguous rows and columns

  • My ipod touch won't do anything (At All!)

    My ipod touch newest model will not charge, turn on, reset, or do anything and it is not recognized when i plug it in to my usb 2.0 and turn on itunes (by itunes or my computer.) I have also tried multiple usb ports A few days ago it worked fine, as