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
Similar Messages
-
Probelm with Union all in view
I'm tring to create a view by using the following:
SELECT MASTER_IDX.MASTER_IDX_ID, CREATE_BY AS PERSON, CREATE_DATE AS WORKDATE, 'CREATE' AS WORKTYPE
FROM MASTER_IDX
WHERE CREATE_BY <> 'IQS'
UNION ALL
SELECT MASTER_IDX.MASTER_IDX_ID, INDEX_BY AS PERSON, INDEX_DATE AS WORKDATE, 'INDEX' AS WORKTYPE
FROM MASTER_IDX
WHERE INDEX_BY <> 'IQS'
UNION ALL
SELECT MASTER_IDX.MASTER_IDX_ID, VER_BY AS PERSON, VER_DATE AS WORKDATE, 'INDEX' AS WORKTYPE
FROM MASTER_IDX
WHERE VER_BY <> 'IQS'
UNION ALL
SELECT MASTER_IDX.MASTER_IDX_ID, MOD_BY AS PERSON, MOD_DATE AS WORKDATE, 'INDEX' AS WORKTYPE
FROM MASTER_IDX
WHERE MOD_BY <> 'IQS'
UNION ALL
SELECT MASTER_IDX.MASTER_IDX_ID, MAILBACK_BY AS PERSON, MAILBACK_DATE AS WORKDATE, 'INDEX' AS WORKTYPE
FROM MASTER_IDX
WHERE MAILBACK_BY <> 'IQS'
UNION ALL
SELECT IDX_IMAGE.MASTER_IDX_ID, SCANNED_BY AS PERSON , SCANNED_DATETIME AS WORKDATE, 'SCANNED' AS WORKTYPE
FROM IDX_IMAGE
WHERE SCANNED_BY <> 'IQS'
when I run this in the sql developer environment I get the results that I expect. When I try to put this into a view I get this error:
java.lang.NullPointerException
Can anyone please look at this and give me a clue as to what i'm doing worng?
Thanks!Can you give a bit more detail about which SQL Developer version you are using, what you mean by "put this into a view" (using the "New View ..." window?) and just what you were doing when you got the NPE (ie Test Syntax or OK to create or something else)?
theFurryOne -
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. -
I am facing a problem to creating a view.
My table data like
row col
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
I want to create a view like this as fields
row,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10
problem is sometimes col values upto 10 and some times col values less than 10
Suppose my data is
row col
1 1
1 2
1 3
1 4
1 5
1 10
2 1
2 2
2 3
2 4
2 5
then also i want view like
row,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10
and col6,col7,col8,col9,col10 are as null values.
If any body have idea to solve this issue, please help me
Advance Thanking,
siju AbrahamIf you search on this forum for the word "pivot", you'll see lots of examples of queries using max(decode(...)).
Regards,
Rob. -
Inventory on Hand Report - Using Union ALL - need two fields to be part of the group
Hi all,
I have created an Inventory "on Hand" Report that takes the Current Inventory from the Item Entry table and the Sales from Unposted Sales Line table and Transfers in and out from the Unposted Transfer Line table. I have joined the tables
using the UNION ALL function.
My problem is that the Transfer table has two locations whereas the other tables only have one. I am grouping on Location code from the Item Entry table which is equivalent to BOTH Transfer from location and the Transfer to.
As an example, there are 15lbs of inventory for Product A in Location #1 with a transfer out of 15 lbs. The Transfer out is going to Location #2
I don't know how to write the query or set up the group so that it recognizes both the Transfer to and the Transfer From fields
I want the report to look similar to the one below but I can only get it to show one of the locations. Is there some way to use the Union function and have one field in the first table be or equivalent to two fields in another?
Location Code
Item No.
Lbs
Sales Orders
Transfer Out
Transfer In
Available Inventory
Location #1
Product A
15
-15
Location #1
15
-15
Location #2
Product A
15
15
Location #2
15
15Hi Igor,
You can get a custom sort order added to your IP column without the need for a second column.
Consider that the sorting is done strictly left-to-right across a string in the column. The string can be any valid HTML content. So, you could wrap your string within, say, a SPAN tag and add an attribute to that tag that contains the sort order you need before the text that is displayed to the user. As long as the attribute is correctly structured (that is, all instances are of the same length, for example), then sorting will work correctly. For example:
SELECT
'<span title="' || PAD_IP_ADDRESS(IP) || '">' || IP || '</span>' Y
FROM ...Now you need to ensure that the PAD_IP_ADDRESS() function returns the correct values. In IP addresses, you have anything from "0.0.0.0" to "255.255.255.255". To get them to sort "numerically", you need to pad one or two digit numbers to get three digit numbers for each value - so, "0.0.0.0" becomes "000.000.000.000". You could create a function to do this - something like:
CREATE OR REPLACE FUNCTION PAD_IP_ADDRESS
pIP IN VARCHAR2
RETURN VARCHAR2
IS
vIP VARCHAR2(15);
vTEMP APEX_APPLICATION_GLOBAL.VC_ARR2;
vSEP VARCHAR2(1);
BEGIN
vSEP := '';
vIP := '';
vTEMP := APEX_UTIL.STRING_TO_TABLE(pIP,'.');
FOR x IN 1..vTEMP.COUNT
LOOP
vIP := vIP || vSEP || TRIM(TO_CHAR(TO_NUMBER(vTEMP(x)),'000'));
vSEP := '.';
END LOOP;
RETURN vIP;
END;The output from this would look something like:
<span title="001.001.001.001">1.1.1.1</span>
<span title="002.255.255.255">2.255.255.255</span>
<span title="010.001.199.098">10.1.199.098</span>Andy -
Materialized view issue with spatial index and UNION all.
Hi guys,
I'm trying to build the following materialized view:
create materialized VIEW MV_ElectricalStuffs
refresh fast
AS
SELECT jb.ROWID,
jb.FID,
JB.NAME_NUMBER
FROM EL_BUS_BAR jb
UNION ALL
SELECT INC.ROWID,
INC.FID,
NULL,
INC.NAME_NUMBER
FROM EL_INTERNAL_CELL INC;
I have this error showing up:
ORA-12015: cannot create a fast refresh materialized view from a complex query
This is because the table EL_INTERNAL_CELL has a SDO_GEOMETRY column that has a spatial index, whose ddl is
CREATE INDEX EL_INTERNAL_CELL_S ON EL_INTERNAL_CELL (GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS('SDO_INDX_DIMS=2 TABLESPACE=USERS LAYER_GTYPE=COLLECTION');
When I remove the spatial index from EL_INTERNAL_CELL column GEOM, Oracle is very happy and creates the view.
Is there a mean however to keep the spatial index in the materialized view?I've managed to drop the spatial index prior to create the materialized view and it is ok. After the materialized view creation, I've recreated the spatial index on the table and all ran smooth. Hope nothing will go bad in the future because of this trick on spatial index..
-
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?
-
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. -
Transaction I view for WebGui(Html) creation problem
Hi All,
I am creating a transaction Iview for WebGui, I am done with I view creation part but when I open the I view its giving
<b>No switch made to HTTPS; so it is unsafe to send your password</b>.
SSO between was and ecc is working fine. I read postings related this issue. No one is able to get the proper solution. I mean why it is happening and how to fix it. Please let me know if any knows how to fix this.
Thanks
KeerthiHi keerthi,
SSO is between???
and also one more thing check the preview of IVIEW, if iview is perfect then i dont think so there is any problem.
Thanks
Purav -
Using timestamp in union all view
I am having a silly problem with one of my views. It is a union all with two select statements. There is a timestamp(6) in one select but not in the other so I have a to_timestamp(null) to match up the columns.
The problem is that no matter how I code the to_timestamp(null,fmt) the structure of the view is always timestamp(0). I even changed the 2nd select so that it uses a timestamp(6) column. If I create 2 views from both selects they have the correct syntax but as soon as I use a union the timestamp loses it precision.
When I acutally do a select from the view I can still see the milliseconds precision. My real problem occurs in that I have a ref cursor that is of type view_row%rowtype. When I select into the cursor I lose the precision.
Any ideas?
thxUse the cast function to cast the timestamp to timestamp(6)
SQL> create table t
2 ( id number
3 , ts timestamp(6)
4 );
Table created.
SQL> create view v
2 as
3 select id, ts
4 from t
5 union all
6 select 0, cast(to_timestamp(null) as timestamp(6))
7 from dual;
View created.
SQL> desc v
Name Null? Type
ID NUMBER
TS TIMESTAMP(6)
SQL> insert into t
2 values (1,systimestamp);
1 row created.
SQL> select * from v;
ID
TS
1
31-AUG-04 02.28.38.342412 PM
0 -
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 -
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. -
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
Maybe you are looking for
-
How to index loops on a MacBook Pro?
I am on a MacBook Pro Laptop. I want to keep the Apple Jam Packs on my portable external 320gb Hard Drive. I try dragging and dropping them from my hard drive in into Garage Band's Loop Browser and it asks me if I want it to copy them to my computer
-
While trying to update my iPhone 4 to iOs6 it froze on the connect to itunes screen and i needed to do a restore. But it restored my phone to january 2011 even though i just backed my phone to my laptop up 2 weeks ago. I still have all my contacts bu
-
THERE SEEMS TO BE NO RHYME OR REASON TO THIS. THE EXCLAMATION POINT APPEARS ON SONGS THAT I HAVE PURCHASED AND DOWNLOADED AND ON SONGS THAT I DOWNLOADED FROM MY OWN CDs. ONCE THE ! APPEARS, THE SONG WON'T PLAY. IT'S ALWAYS THE SAME SONGS THAT THIS
-
Beginners guide to Powerbook settings when giving a lecture needed....
Could someone direct me as to how I set up my PowerBookG4 and projector for my keynote lecture (1st one!). It's stressful enough giving the lecture - I don't want my projection to look like crap as well! Regards Wkka G5 Dual 1.8 GHz/ Ext FW La Cie 20
-
my n73 me is shutdown plz help me my FW version is i forgot i update my FW version to n73 me and my pc is auto shutdown and my updating loading is stop and my n73me is turn off and i cant turn on please help