Multiple UNION ALL views within a view returning incorrect records?
Hi,
I have a view which selects from multiple views with UNION ALL joining them. If I just select from the larg UNION ALL query I return more records (correct amount) than If I create a view, and select from it.
e.g.
SELECT *
FROM vw_load_1
UNION ALL
SELECT *
FROM vw_load_2
UNION ALL
SELECT *
FROM vw_load_3
UNION ALL
SELECT *
FROM vw_load_4
UNION ALL
SELECT *
FROM vw_load_5
Returns 405 Records
but
CREATE VIEW vw_master_load
AS
SELECT *
FROM vw_load_1
UNION ALL
SELECT *
FROM vw_load_2
UNION ALL
SELECT *
FROM vw_load_3
UNION ALL
SELECT *
FROM vw_load_4
UNION ALL
SELECT *
FROM vw_load_5;
SELECT COUNT(*)
FROM vw_master_load
Returns 307 records
Can anyone explain why, or how to get around this?
Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
Hi,
Are you saying that you run:
select count(*) from (
SELECT *
FROM vw_load_1
UNION ALL
SELECT *
FROM vw_load_2
UNION ALL
SELECT *
FROM vw_load_3
UNION ALL
SELECT *
FROM vw_load_4
UNION ALL
SELECT *
FROM vw_load_5
result is: 307 And then you run
SELECT *
FROM vw_load_1
UNION ALL
SELECT *
FROM vw_load_2
UNION ALL
SELECT *
FROM vw_load_3
UNION ALL
SELECT *
FROM vw_load_4
UNION ALL
SELECT *
FROM vw_load_5
returns 405 rowsIf so, that is very strange.
Can you an example we can re-produce?
Regards,
Peter
Similar Messages
-
Crystal returning incorrect records
I have a report that contains one table and one subreport. When the report is refreshed it randomly mixes records together. This error occurs in the container report only, I have even removed the sub report and refreshed with the same results.
For example the report may contain 25 people (records), each record shows the persons name, address, Login code and Password code. I should always see Jane Doe with her address and log in codes listed together, then Joe Smith with his address and login codes, etc. However, I end up getting Jane Doe with all of her correct information and then Jane Doe again with Joe Smith's address and login codes. If I refresh again, it will change to different peoples records being mixed up. Each refresh comes back with different results.Thank you Zack, I had initially thought that it would be a link issue as well, until I realized that this report was built using only one table. The only linking that is in the report is the subreport link, which I checked and even removed the sub report all together to see if the problem resolved itself, but it did not.
I also located another report using the same table and sub report. I was able to get this report to work perfectly, which is why I am so baffled at the original reports issue. The two reports appear to be identical. At this point I have solved the users issue by using the second report to replace the broken one, but I would really like to understand what is causing the issue for future use. -
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 -
Performing UNION/UNION ALL in views
I have two databases (DB1 AND DB2) in same server. I have to create two views (V1 AND V2) respectively in DB1 and DB2. And I have to make an union/union all operation in these views (V1 and V2). Is this possible.???.
Or can I create a single view instead of two views in such a way that the single view contains an union/union all operation between the data taken from two DBs (DB1 and DB2).?
Any ideas or suggestions on these questions. Your help is well appreciated.
Thanks in advance.Or can I create a single view instead of two views in such a way that the single view contains an union/union all operation between the data taken from two DBs (DB1 and DB2).?
Make sure you do very thorough testing if you plan to use UNION since that requires a sort operation. And that means that the data from one query has to be sent to the other server before it can be sorted.
So a query issued on DB1 might sent the DB1 data to DB2 and then send the sorted result back to DB1. But the same query issued on DB2 would already have the DB2 data so after the DB1 data is sent to DB2 and sorted the query is done.
That is, in one case the entire result set may be sent over the network from one server to the other instead of just one table. -
Hi ,
i have requirement in which i have embedded window within another window Ex: i have embedded search view within create view, in which i have set create preporty "default - false" and search preporty "default - true", so whenever i run create application, search screen is display. The requirement is, there is button in search as "create" when i click on that it should navigate on to create screen. How to do that?Absolutely. Whilst it maybe silly to keep two seperate databases, I am quite happy to have the P&S pics in iPhote and my dslr pics in Aperture (my wife prefers this also). So, not one pic in iPhote is actually in Aperture. My only gripe with using iPhoto's capability to 'show' the Aperture library is the default small window they get opened in. This is the original OP, how to lock this library window size to maximum, once dragged larger. She is very apt using iPhoto for e-mailing and I would like for her to access this option of viewing my Aperture files, in a larger format. Who knows, maybe it's just not possible and the window has to be dragged larger everytime.
Cheers -
0Employee_Text master data returns 0 records with Full load
Hi All
0Employee master data texts returns 0 records with full update. I checked PA0000 table and it has 22K records. I am not sure what is missing.
Thanks for your help in advance.
LathaHi again Latha,
I've been checking the extractor 0EMPLOYEE_TEXT (RSA3 in debbug mode) and it gets data from table view V_BW_PA0001_ENM check if you allready have entries in this database view (it's a view from PA0001 with select condition PA0001-SPRPS eq ''.
If you have entries here you should get them with the extractor.
The notes solves extraction problems with several objects (in our case was 0ORGUNIT).
I hope this helps,
Regards.
Carlos. -
Extractors in CRM returning 0 records
hello evryone,
could anyone please let me know, if they have come across these Extractors such as 0CRM_CONTACT_OUT,0CRM_OPPT_H,0CRM_OPPT_I how do they really work, upon some requirement i need these datasources in use. when i try to extractor check in rsa3 all these 3 extractors are returning 0 records for the full mode. could anyone please let me know, how to work on them to pull the data from these extractors to BI.Hi dear,
if you are working with LC datasource, you have to tun setup job to fill setup table in order to be able to see something with RSA3 !
Try OLI7BW for orders (application comp.11)
OLI8BW for 12
OLI9BW for 13
(don't forget to empty via LBWG these tables before filling them to avoid data duplication!!!)
Hope it helps!
Bye,
Roberto -
Strange behaviour of view based on several tables join with union all
Dear fellows we r facing a strange problem we have a view based on several tables joined by union all ,when we issue an ordered query on date,rows returned are unusually different than they should be .
Is oracle has some special behaviour for view based on union all ?
I m using oracle 8.1.6 on windows 2000
Kashif SohailDid you ever solve this problem? I have two select statements based on 4 tables and 3 views using about 5 more tables. When I execute each select individually I get exactly what is expected. When I UNION ALL both selects together, I get "no rows returned", however when I UNION them I get exactly what is expected. I should get the same answer for both UNION ALL and UNION. The two select statements are identical, except for one column where I changed the constant to be different. Any thoughts?
-
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. -
OAF Export button fetching data in one column - view object using union all
Dear All,
Export button showing data in one column from view object,
View object is based on mulitple queries with union all ,
Please let me know the solution for this issue.
Thanks
Maheswara RajuMaheswara Raju,
As per my understanding you are not able to export all the View Attribute using export Button. Only the attribute which is used with the item/region will get exported.
There are few work around in case if you want to export the column without showing on OAF Page. Let me know.
Cheers
Gyan -
Return multiple controls from a JS type view.
Hello All,
I am a novice to SAPUI5 and web development so please bear with me as this could be a very basic question about SAPUI5.
I am trying to develop a simple view (CalcView.js)which is of type javascript. I need to place 8 drop down boxes in this view. I am able to created one of these drop downs using var oPropertyType = new sap.ui.commons.DropdownBox syntax which is populated based on the data received from a REST call.
When I create just one of the drop down and write 'return oDropDown1' at the end of the createcontent method of this view, all works fine and I can see this drop down. Here is where the challenge starts for me. When I now create more than 1 drop downs how do I get them to appear on the page? In this case return statement won't work as I now have to return more than 1 control (drop downs) back.
I have structured my project such that I have index.html which looks like this...
My Application.js looks like this...
jQuery.sap.declare("Application"); jQuery.sap.require("sap.ui.app.Application"); sap.ui.app.Application.extend("Application", { init : function() { var model = new sap.ui.model.odata.ODataModel("proxy/sap/opu/odata/sap/ZCONSUMPTIONCALC_SRV/", true, "VORANIJ", "desktop1",null,true, true); var imgModel = new sap.ui.model.json.JSONModel("model/img.json"); sap.ui.getCore().setModel(model); sap.ui.getCore().setModel(imgModel, "img"); }, main : function() { // create app view and put to html root element var root = this.getRoot(); sap.ui.jsview("app", "view.App").placeAt(root); } });My Appview.js looks like this...
sap.ui.jsview("view.App", { /** * Specifies the Controller belonging to this View. In the case that it is * not implemented, or that "null" is returned, this View does not have a * Controller. * * @memberOf view.App */ getControllerName : function() { return "view.App"; }, /** * Is initially called once after the Controller has been instantiated. It * is the place where the UI is constructed. Since the Controller is given * to this method, its event handlers can be attached right away. * * @memberOf view.App */ createContent : function(oController) { var shell = new sap.ui.ux3.Shell({ appTitle : "Consumption Calculator", appIcon : "img/BG_Logo.png", showFeederTool : false, showInspectorTool : false, showSearchTool : false, showLogoutButton : false, worksetItems : [ new sap.ui.ux3.NavigationItem({ text : "" }) ] }); var view = sap.ui.view({ id : "idCalculator", viewName : "view.Calculator", type : sap.ui.core.mvc.ViewType.JS }); shell.setContent(view); this.oShell = shell; return this.oShell; } });And finally my Calculator view (the one in question) looks like this...
sap.ui.jsview("view.Calculator", { /** * Specifies the Controller belonging to this View. In the case that it is * not implemented, or that "null" is returned, this View does not have a * Controller. * * @memberOf view.Calculator */ getControllerName : function() { return "view.Calculator"; }, /** * Is initially called once after the Controller has been instantiated. It * is the place where the UI is constructed. Since the Controller is given * to this method, its event handlers can be attached right away. * * @memberOf view.Calculator */ createContent : function(oController) { var oPropertyType = new sap.ui.commons.DropdownBox({ id : "proptype", tooltip : "Property Type", width : "350px" }); var oItemPropType = new sap.ui.core.ListItem(); oItemPropType.bindProperty("key", "Characteristic"); oItemPropType.bindProperty("text", "Description"); oItemPropType.bindProperty("enabled", "enabled"); var oFiltPropType = new sap.ui.model.Filter("Group_I",sap.ui.model.FilterOperator.EQ,"PROPERTY"); oPropertyType.bindItems("/UI_Values",oItemPropType,null,oFiltPropType); var oLabPropTyp = new sap.ui.commons.Label("LabelPropTyp",{ text: "Property Type:", labelFor: oPropertyType}); return oPropertyType; } });Any help around this will be really appreciated.
Regards,
JayHi,
Just place the items you want to return in a Container and then return the container, ie a Panel, a FlexBox or a Layout will do
sap/ui/commons/demokit/Panel.html -
I have been working on a book and have 418 photos already in my book. All of a sudden I cannot access the book module and clicking on the multiple view, spread view, or single view does not take me back to the book I have been working on. I can no longer see my book although I still see the collection with 418 photos under collections. What I do see is a blank template for a new book and I can't find the unfinished book I started with 418 photos. It is like the new empty template is somehow covering it up. How do I get back to the book I have been working on?
Is it possible you mistakenly clicked on a [Clear Layout] button?
But a great hint is- Always click on the [Create a Saved Book] button, early in your new book design.
Then you have a permanent link to the book in the Collections panel. (In addition to the standard collection of your selected images)
Note: a Book Collection shows an icon that looks like a book.
Every time you come back to edit the book, open the Book Module by clicking on the white arrow that appears on the end of your Book Collection title. (The title as saved)
Re-opening a book without using the "Saved Book" option can have unpredictable results.
A "Book" Collection is like a "Smart Collection" because anything you do to the book design, change pages, change images, etc, is automatically updated in the Saved Book collection. -
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 suggestionLooks 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 ;-) -
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
RajivHi 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
Maybe you are looking for
-
How to: make a custom second page?
Ladies, Gents, I almost have my custom template for my business correspondence ready, but there is one thing I cannot figure out how to do it... As with my normal (printed) stationary, my second page and onward have less information then my first one
-
How to execute OMB scripts from the command prompt of OS
Hi I want to deploy the mapping from one environment to other environment using OMB script language. But I dont want to run the OMB scripts from OMB plus COmmand prompt? All I need is , is there any way/scripts to access OMB command prompt from the g
-
Image Swap or Rolloover Image?
I am working in CS3 DreamWeaver and trying to make a gallery of smaller images that show a larger version of the image when the mouse rolls over it. What is the best way to accomplish this? The smaller buttons are in a row and the larger image shows
-
Secure Backup with PowerVault 124T?
Does anyone know if Oracle Secure Backup is supported with / or will work with Dell PowerVault 124T LTO-3 Autoloader? I looked on the compatibility matrix, but it's not on there. Although there are other Dell products that are similar (like 126T, 130
-
I have a video gallery that has 24 different videos to choose from. I am trying to find a way that a user can pick from the 24 to create a new customized list of videos to play. The idea is that a sales rep could choose the videos they want to show t