View joining two spatial tables and strange CBO behaviour
Hi all,
I've following view in my database:
CREATE OR REPLACE VIEW my_view AS
SELECT id, 'table1' AS source, location FROM my_table1
UNION ALL
SELECT id, 'table2' AS source, location FROM my_table2;
When I execute query:
SELECT * FROM my_view WHERE SDO_RELATE(location, SDO_GEOMETRY(...), 'mask=anyinteract') = 'TRUE';
It works as expected.
When running query like (getting location with subquery):
SELECT * FROM my_view WHERE SDO_RELATE(location, (SELECT location FROM my_table3 WHERE id = 123, 'mask=anyinteract') = 'TRUE';
It doesn't work. Oracle Throws "DatabaseError: ORA-13226: interface not supported without a spatial index"
Further investigation revealed strange behaviour of CBO:
In first case Oracle CBO uses Spatial index just fine and as expected.
But second query and CBO get's a bit strange - unique index scan is used for subselect, but for view tables is full table scan is used and SDO_RELATE is not happy with that since no spatial index is used.
How I can use spatial indexes regardless of that subselect?
Hi folks,
Looking over these responses and not finding a lot of clarity yet in terms of leaving a trail for future readers to glean an answer from. I was just looking through the back-and-forth and curious myself about the issue First of all I think Jani's observations are quite on target. This CBO reaction is weird and does not work they way most Oracle users would expect it to work. Secondly, Jani really should tell us his Oracle version and folks providing answers should as well - the CBO is always being tweaked. Thirdly, Stefan provides a solution though it's a rather expensive solution to my taste. And finally, I think we as a group need to spend a bit more time reproducing things in code. I will give it a shot, feel free to correct anything I got wrong.
So first of all, I wrote this up quick on 12.1.0.2 and verified it was the same on 11.2.0.4
DROP TABLE my_table1 PURGE;
CREATE TABLE my_table1(
objectid INTEGER NOT NULL
,tsource VARCHAR2(30 Char)
,shape MDSYS.SDO_GEOMETRY
,PRIMARY KEY(objectid)
DROP TABLE my_table2 PURGE;
CREATE TABLE my_table2(
objectid INTEGER NOT NULL
,tsource VARCHAR2(30 Char)
,shape MDSYS.SDO_GEOMETRY
,PRIMARY KEY(objectid)
DROP TABLE my_table3 PURGE;
CREATE TABLE my_table3(
objectid INTEGER NOT NULL
,tsource VARCHAR2(30 Char)
,shape MDSYS.SDO_GEOMETRY
,PRIMARY KEY(objectid)
CREATE OR REPLACE PROCEDURE seeder(
p_count IN NUMBER
AS
sdo_foo MDSYS.SDO_GEOMETRY;
int_counter NUMBER := 1;
FUNCTION random_line
RETURN MDSYS.SDO_GEOMETRY
AS
num_x1 NUMBER;
num_y1 NUMBER;
num_offx NUMBER;
num_offy NUMBER;
BEGIN
num_x1 := dbms_random.value(-179,179);
num_y1 := dbms_random.value(-89,89);
RETURN MDSYS.SDO_GEOMETRY(
2002
,8265
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(
num_x1
,num_y1
,num_x1 + 0.0001
,num_y1 + 0.0001
END random_line;
BEGIN
FOR i IN 1 .. p_count
LOOP
sdo_foo := random_line();
INSERT INTO my_table1
VALUES (
int_counter
,'table1'
,sdo_foo
int_counter := int_counter + 1;
sdo_foo := random_line();
INSERT INTO my_table2
VALUES (
int_counter
,'table2'
,sdo_foo
int_counter := int_counter + 1;
sdo_foo := random_line();
INSERT INTO my_table3
VALUES (
int_counter
,'table3'
,sdo_foo
int_counter := int_counter + 1;
END LOOP;
INSERT INTO my_table1
VALUES (
0
,'table1'
,MDSYS.SDO_GEOMETRY(
2002
,8265
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(
-87.8211111
,42.5847222
,-87.8212
,42.5848
INSERT INTO my_table3
VALUES (
0
,'table3'
,MDSYS.SDO_GEOMETRY(
2002
,8265
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(
-87.8211111
,42.5848
,-87.8212
,42.5847222
COMMIT;
END seeder;
BEGIN
seeder(100000);
END;
SELECT 'my_table1: ' || COUNT(*) AS invalid_count FROM my_table1 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE'
UNION ALL
SELECT 'my_table2: ' || COUNT(*) AS invalid_count FROM my_table2 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE'
UNION ALL
SELECT 'my_table3: ' || COUNT(*) AS invalid_count FROM my_table3 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE';
BEGIN
INSERT INTO user_sdo_geom_metadata(
table_name
,column_name
,diminfo
,srid
) VALUES (
'MY_TABLE1'
,'SHAPE'
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
,8265
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
BEGIN
INSERT INTO user_sdo_geom_metadata(
table_name
,column_name
,diminfo
,srid
) VALUES (
'MY_TABLE2'
,'SHAPE'
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
,8265
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
BEGIN
INSERT INTO user_sdo_geom_metadata(
table_name
,column_name
,diminfo
,srid
) VALUES (
'MY_TABLE3'
,'SHAPE'
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
,8265
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
CREATE INDEX my_table1_spx ON my_table1
(shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
NOPARALLEL;
CREATE INDEX my_table2_spx ON my_table2
(shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
NOPARALLEL;
CREATE INDEX my_table3_spx ON my_table3
(shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
NOPARALLEL;
BEGIN
dbms_stats.gather_table_stats(USER, 'MY_TABLE1');
dbms_stats.gather_index_stats(USER, 'MY_TABLE1_SPX');
dbms_stats.gather_table_stats(USER, 'MY_TABLE2');
dbms_stats.gather_index_stats(USER, 'MY_TABLE2_SPX');
dbms_stats.gather_table_stats(USER, 'MY_TABLE3');
dbms_stats.gather_index_stats(USER, 'MY_TABLE3_SPX');
END;
CREATE OR REPLACE VIEW my_view
AS
SELECT
objectid
,'table1' AS tsource
,shape
FROM
my_table1
UNION ALL
SELECT
objectid
,'table2' AS tsource
,shape
FROM my_table2;
set timing on;
-- QUERY #1
-- Jani's original setup, works as expected
SELECT
COUNT(*) AS single_geom_counter
FROM
my_view a
WHERE
MDSYS.SDO_RELATE(
a.shape
,MDSYS.SDO_GEOMETRY(
2002
,8265
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(
-87.8211111
,42.5848
,-87.8212
,42.5847222
,'mask=anyinteract'
) = 'TRUE';
-- QUERY #2
-- Now the problem statement
SELECT
COUNT(*) AS table_problem_counter
FROM
my_view a
WHERE
MDSYS.SDO_RELATE(
a.shape
,(SELECT b.shape FROM my_table3 b WHERE b.objectid = 0)
,'mask=anyinteract'
) = 'TRUE';
-- QUERY #3
-- Stefan's solution
SELECT /*+ ORDERED */
COUNT(*) AS stefans_solution
FROM
my_table3 a
,my_view b
WHERE
a.objectid = 0
AND MDSYS.SDO_RELATE(
a.shape
,b.shape
,'mask=anyinteract'
) = 'TRUE';
Anyhow, so the hard coded query #1 that Jani provided works exactly the way most folks would expect, the second item in the relate is applied to each spatial index participating in the view. I think we can agree this is what we want.
Now when we move on to the problem, well its all goes off the rails as I think its looks to apply the spatial filter to the view itself which lacks an index (not sure really)
So as Stefan says, you can work around this by rewriting things as query #3 does above though now its a full table scan of both tables in the view. This is a long way performance wise from Query #1!
So on my 12c test box
query #1 Elapsed: 00:00:00.016
query #3 Elapsed: 00:00:33.534
On 11g production box
query #1 Elapsed: 00:00:00.49
query #3 Elapsed: 00:02:31.45 (ouch!)
So hopefully someone else can jump in with more information on better solutions?
I overall tend to avoid the kind of unioned views that Jani is using here. I have a hard time recalling why but I must have been burned similarly many years ago when I was first starting with Oracle spatial. I tend to always want my spatial indexes right there where I can keep a grim stink eye on them. It may be that a unioned view with multiple spatial indexes behind it might just be a bad practice better done with a materialized view? Or maybe a lesser term? Unprofitable practice? fraught? "Best if you don't do that"?
Anyhow, I would be interested in what others have as input on the matter.
Cheers,
Paul
Similar Messages
-
Join two source tables and replicat into a target table with BLOB
Hi,
I am working on an integration to source transaction data from legacy application to ESB using GG.
What I need to do is join two source tables (to de-normalize the area_id) to form the transaction detail, then transform by concatenate the transaction detail fields into a value only CSV, replicate it on the target ESB IN_DATA table's BLOB content field.
Based on what I had researched, lookup by join two source tables require SQLEXEC, which doesn't support BLOB.
What alternatives are there and what GG recommend in such use case?
Any helpful advice is much appreciated.
thanks,
XiaocunXiaocun,
Not sure what you're data looks like but it's possible the the comma separated value (CSV) requirement may be solved by something like this in your MAP statement:
colmap (usedefaults,
my_blob = @STRCAT (col02, ",", col03, ",", col04)
Since this is not 1:1 you'll be using a sourcedefs file, which is nice because it will do the datatype conversion for you under the covers (also a nice trick when migrating long raws to blobs). So col02 can be varchar2, col03 a number, and col04 a clob and they'll convert in real-time.
Mapping two tables to one is simple enough with two MAP statements, the harder challenge is joining operations from separate transactions because OGG is operation based and doesn't work on aggregates. It's possible you could end up using a combination of built in parameters and funcations with SQLEXEC and SQL/PL/SQL for more complicated scenarios, all depending on the design of the target table. But you have several scenarios to address.
For example, is the target table really a history table or are you actually going to delete from it? If just the child is deleted but you don't want to delete the whole row yet, you may want to use NOCOMPRESSDELETES & UPDATEDELETES and COLMAP a new flag column to denote it was deleted. It's likely that the insert on the child may really mean an update to the target (see UPDATEINSERTS).
If you need to update the LOB by appending or prepending new data then that's going to require some custom work, staging tables and a looping script, or a user exit.
Some parameters you may want to become familiar with if not already:
COLS | COLSEXCEPT
COLMAP
OVERRIDEDUPS
INSERTDELETES
INSERTMISSINGUPDATES
INSERTUPDATES
GETDELETES | IGNOREDELETES
GETINSERTS | IGNOREINSERTS
GETUPDATES | IGNOREUPDATES
Good luck,
-joe -
Joining Two Internal Tables - ( Urgent )
Could anybody please give me the whole code for joining two internal tables
and putting the data in a third internal table. Please, very urgent.
Regards,
SAURAVHi,
Refer this code
*& Form SUB_READ_VBRK
text
FORM sub_read_vbrk.
SELECT vbeln
rplnr
bukrs
FROM vbrk
INTO TABLE it_vbrk
WHERE vbeln IN s_vbeln
AND rplnr NE ' '.
IF sy-subrc EQ 0.
SORT it_vbrk BY rplnr.
ENDIF.
ENDFORM. " SUB_READ_VBRK
*& Form SUB_READ_FPLTC
text
FORM sub_read_fpltc.
IF NOT it_vbrk[] IS INITIAL.
SELECT fplnr
fpltr
ccnum
FROM fpltc
INTO TABLE it_fpltc
FOR ALL ENTRIES IN it_vbrk
WHERE fplnr EQ it_vbrk-rplnr
AND ccins EQ 'GIFC'.
IF sy-subrc EQ 0.
SORT it_fpltc BY fplnr.
ENDIF.
ENDIF.
ENDFORM. " SUB_READ_FPLTC
*& Form SUB_COLLECT_DATA
text
FORM sub_collect_data.
*--Local variables
DATA : lv_count(3) TYPE c.
IF NOT it_fpltc[] IS INITIAL.
LOOP AT it_fpltc INTO wa_fpltc.
lv_count = wa_fpltc-fpltr+3(3).
wa_final-ccnum = wa_fpltc-ccnum.
wa_final-rfzei = lv_count.
CLEAR : wa_vbrk.
READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_final-vbeln = wa_vbrk-vbeln.
wa_final-bukrs = wa_vbrk-bukrs.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_vbrk,
wa_fpltc,
lv_count.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_COLLECT_DATA
Regards,
prashant -
How to provide joins between oracle tables and sql server tables
Hi,
I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server.
how to provide joins between oracle tables and sql server tables ? Any help on this
Regards,
Malliuser10675696 wrote:
I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server. Bad idea most times. Heterogeneous joins do not exactly scale and performance can be severely degraded by network speed and b/w availability. And there is nothing you can do in the application and database layers to address performance issue at the network level in this case - your code's performance is simply at the mercy of network performance. With a single glaring fact - network performance is continually degrading. All the time. Always. Until it is upgraded. When the performance degradation starts all over again.
If the tables are not small (few 1000 rows each) and row volumes static, I would not consider doing a heterogeneous join. Instead I would rather go for a materialised view on the Oracle side, use a proper table and index structure, and do a local database join. -
Join two xmltype table using Xquery
I am wondering how to join two xmltype tables in xml db database. both tables are schema based object-relational tables.
these are the examples:
academicProgram table contain batch of academicprogram.xml entries
<academicProgram>
<listOfCourse>
<course><id>1</id></course>
<course><id>2</id></course>
</listOfCourse>
</academicProgram>
course table contain all the course entries, each of them is an xml file based on the the course schema. for example,
course1.xml
<course>
<id>1</id>
<title>xxxxxxx</title>
<description>xxxxxxxxxxxxxx</description>
</course>
I used the following xquery code to merge the detailed course information from course table to the academic program information
select *
from XMLTable(
for $program in ora:view("HTU", "ACADEMICPROGRAM")
return <academicProgram xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"
for $node in $program/academicProgram/node()
return if (name($node) eq "listOfCourse")
then (
<listOfCourse>{
for $i in $node/course
for $j in ora:view("HTU", "COURSE")/course
where $i/id eq $j/id
return $j
}</listOfCourse>
else $node
</academicProgram>
it did return what I want, but the problem is it take more than 5 minutes to finish. is there someway to make it run faster? I have been struggling for a week, please help.
thanks in advance.
HailiDoes this work...
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> set autotrace on explain
SQL> set lines 150 pages 0 long 10000
SQL> --
SQL> begin
2 :schemaURL := 'http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/custom.xsd';
3 :schemaPath := '/public/custom.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<xs:schema xmlns:apcustom="http://www.mdanderson.org/schema/APEP/custom" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="
http://www.mdanderson.org/schema/APEP/custom" elementFormDefault="qualified" attributeFormDefault="unqualified">
5 <xs:element name="CourseCatalogCustomDataType">
6 <xs:annotation>
7 <xs:documentation>Comment describing your root element</xs:documentation>
8 </xs:annotation>
9 </xs:element>
10 </xs:schema>');
11 begin
12 if (dbms_xdb.existsResource(:schemaPath)) then
13 dbms_xdb.deleteResource(:schemaPath);
14 end if;
15 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
16 end;
17 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> begin
2 :schemaURL := 'http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd';
3 :schemaPath := '/public/courseCatalog.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<?xml version="1.0" encoding="UTF-8"?>
5 <!-- edited with XMLSpy v2006 rel. 3 U (http://www.altova.com) by John Grossman (UT MD Anderson Cancer Center)
6 -->
7 <xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:xs="http://www.w3.
org/2001/XMLSchema" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" targetNamespace="http://www.mdanderson.org/schema/APEP/courseCa
talog" elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true">
8 <xs:import namespace="http://www.mdanderson.org/schema/APEP/custom" schemaLocation="http://aahmb10-147:7575/public/www.mdanderson.or
g/schema/APEP/custom.xsd"/>
9 <!-- ######################################## -->
10 <!-- GLOBAL ELEMENTS -->
11 <!-- ######################################## -->
12 <xs:element name="course" type="CourseType" xdb:defaultTable="COURSE">
13 <xs:annotation>
14 <xs:documentation>Comment describing your root element</xs:documentation>
15 </xs:annotation>
16 </xs:element>
17 <xs:element name="listOfCourse" type="ListOfCourseType" xdb:defaultTable="COURSELIST"/>
18 <xs:element name="courseCatalog" type="CourseCatalogType" xdb:defaultTable="COURSECATALOG"/>
19 <!-- ######################################## -->
20 <!-- GLOBAL TYPES -->
21 <!-- ######################################## -->
22 <xs:complexType name="CompositeIDType" xdb:SQLType="COURSE_COMPOSITEID_T">
23 <xs:sequence>
24 <xs:element name="prefix" xdb:SQLName="PREFIX">
25 <xs:simpleType>
26 <xs:restriction base="xs:string">
27 <xs:length value="2"/>
28 </xs:restriction>
29 </xs:simpleType>
30 </xs:element>
31 <xs:element name="level" type="xs:positiveInteger" xdb:SQLName="COURSELEVEL"/>
32 <xs:element name="creditHours" type="xs:positiveInteger" xdb:SQLName="CREDITHOURS"/>
33 <xs:element name="identNumber" xdb:SQLName="IDENTNUMBER">
34 <xs:simpleType>
35 <xs:restriction base="xs:string">
36 <xs:length value="2"/>
37 </xs:restriction>
38 </xs:simpleType>
39 </xs:element>
40 </xs:sequence>
41 </xs:complexType>
42 <xs:complexType name="CourseType" xdb:SQLType="COURSE_T">
43 <xs:sequence>
44 <xs:element name="id" type="xs:integer" minOccurs="0" xdb:SQLName="ID"/>
45 <xs:element name="compositeID" type="CompositeIDType" minOccurs="0" xdb:SQLName="COMPOSITEID"/>
46 <xs:element name="title" type="xs:string" minOccurs="0" xdb:SQLName="TITLE"/>
47 <xs:element name="description" type="xs:string" minOccurs="0" xdb:SQLName="DESCRIPTION"/>
48 <xs:element name="corequisite" type="CompositeIDType" minOccurs="0" maxOccurs="unbounded" xdb:SQLName="COREQUISITE"
xdb:defaultTable=""/>
49 <xs:element name="prerequisite" type="CompositeIDType" minOccurs="0" maxOccurs="unbounded" xdb:SQLName="PREREQUISITE
" xdb:defaultTable=""/>
50 <xs:element name="availability" minOccurs="0" xdb:SQLName="AVAILABILITY">
51 <xs:complexType>
52 <xs:sequence>
53 <xs:element name="startDate" type="xs:date" minOccurs="0" xdb:SQLName="STARTDATE"/>
54 <xs:element name="endDate" type="xs:date" minOccurs="0" xdb:SQLName="ENDDATE"/>
55 </xs:sequence>
56 </xs:complexType>
57 </xs:element>
58 </xs:sequence>
59 </xs:complexType>
60 <xs:complexType name="ListOfCourseType" xdb:SQLType="COURSE_LIST_T">
61 <xs:sequence minOccurs="0" maxOccurs="unbounded">
62 <xs:element name="id" type="xs:positiveInteger" minOccurs="0" xdb:SQLName="ID"/>
63 <xs:element ref="course" minOccurs="0"/>
64 </xs:sequence>
65 </xs:complexType>
66 <xs:complexType name="CourseCatalogType" xdb:SQLType="COURSE_CATALOG_T">
67 <xs:sequence minOccurs="0">
68 <xs:element name="id" type="xs:positiveInteger" minOccurs="0" xdb:SQLName="ID"/>
69 <xs:element ref="listOfCourse" minOccurs="0"/>
70 </xs:sequence>
71 </xs:complexType>
72 </xs:schema>');
73 begin
74 if (dbms_xdb.existsResource(:schemaPath)) then
75 dbms_xdb.deleteResource(:schemaPath);
76 end if;
77 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
78 end;
79 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> begin
2 :schemaURL := 'http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/academicProgram.xsd';
3 :schemaPath := '/public/academicProgram.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<?xml version="1.0" encoding="WINDOWS-1252"?>
5 <!-- edited with XMLSpy v2006 rel. 3 U (http://www.altova.com) by John Grossman (UT MD Anderson Cancer Center) -->
6 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:ap="http://www.mdanderson.org/sche
ma/APEP/courseCatalog" targetNamespace="http://www.mdanderson.org/schema/APEP/courseCatalog" elementFormDefault="qualified" attributeFormDef
ault="unqualified" xdb:storeVarrayAsTable="true">
7 <xs:include schemaLocation="http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd" />
8 <!-- ######################################## -->
9 <!-- GLOBAL ELEMENTS -->
10 <!-- ######################################## -->
11 <xs:element name="academicProgram" type="ap:AcademicProgramType" xdb:defaultTable="ACADEMICPROGRAM">
12 <xs:annotation>
13 <xs:documentation>Comment describing your root element</xs:documentation>
14 </xs:annotation>
15 </xs:element>
16 <!-- ######################################## -->
17 <!-- GLOBAL Types -->
18 <!-- ######################################## -->
19 <xs:complexType name="ListOfAcademicCredentialType" xdb:SQLType="ACADEMICCREDENTIAL_LIST_T">
20 <xs:sequence minOccurs="0" maxOccurs="unbounded">
21 <xs:element name="credential" type="ap:AcademicCredentialType" minOccurs="0" xdb:SQLName="CREDENTIAL"/>
22 </xs:sequence>
23 </xs:complexType>
24 <xs:complexType name="AcademicCredentialType" xdb:SQLType="ACADEMICCREDENTIAL_T">
25 <xs:sequence minOccurs="0">
26 <xs:element name="id" type="xs:integer" minOccurs="0" xdb:SQLName="ID"/>
27 <xs:element name="field" type="xs:string" minOccurs="0" xdb:SQLName="FIELD">
28 <xs:annotation>
29 <xs:documentation>Academic or professional field for which the credential is granted. Example: Clini
ical Laboratory Science</xs:documentation>
30 </xs:annotation>
31 </xs:element>
32 <xs:element name="typeCode" minOccurs="0" xdb:SQLName="TYPECODE">
33 <xs:annotation>
34 <xs:documentation>The type of credential. Example: Bachelor of Science</xs:documentation>
35 </xs:annotation>
36 <xs:simpleType>
37 <xs:restriction base="xs:string">
38 <xs:enumeration value="Bachelor of Science Degree"/>
39 <xs:enumeration value="Certificate"/>
40 </xs:restriction>
41 </xs:simpleType>
42 </xs:element>
43 </xs:sequence>
44 </xs:complexType>
45 <xs:complexType name="RequirementType" xdb:SQLType="ACADEMICPROGRAM_REQ_T">
46 <xs:sequence minOccurs="0">
47 <xs:element name="typeCode" type="xs:string" minOccurs="0" xdb:SQLName="TYPECODE"/>
48 <xs:element name="description" type="xs:string" minOccurs="0" xdb:SQLName="DESCRIPTION"/>
49 <xs:element name="scope" type="xs:string" minOccurs="0" xdb:SQLName="SCOPE"/>
50 </xs:sequence>
51 </xs:complexType>
52 <xs:complexType name="ListOfRequirementType" xdb:SQLType="ACADEMICPROGRAM_REQ_L_T">
53 <xs:sequence minOccurs="0">
54 <xs:element name="requirement" type="ap:RequirementType" minOccurs="0" xdb:SQLName="REQUIREMENT"/>
55 </xs:sequence>
56 </xs:complexType>
57 <xs:complexType name="AcademicProgramType" xdb:SQLType="ACADEMICPROGRAM_T">
58 <xs:sequence>
59 <xs:element name="name" type="xs:string" minOccurs="0" xdb:SQLName="NAME"/>
60 <xs:element name="description" type="xs:string" minOccurs="0" xdb:SQLName="DESCRIPTION"/>
61 <xs:element name="listOfAcademicCredential" type="ap:ListOfAcademicCredentialType" minOccurs="0"/>
62 <xs:element name="listOfRelatedParty" minOccurs="0" xdb:SQLName="LISTOFRELATEDPARTY"/>
63 <xs:element name="mission" type="xs:string" minOccurs="0" xdb:SQLName="MISSION"/>
64 <xs:element name="goals" type="xs:string" minOccurs="0" xdb:SQLName="GOAL"/>
65 <xs:element name="objectives" type="xs:string" minOccurs="0" xdb:SQLName="OBJECTIVES"/>
66 <xs:element name="competencies" minOccurs="0" xdb:SQLName="COMPETENCIES"/>
67 <xs:element name="selectionProcess" minOccurs="0" xdb:SQLName="SELECTIONPROCESS"/>
68 <xs:element name="listOfRequirement" type="ap:ListOfRequirementType" minOccurs="0"/>
69 <xs:element name="evaluationCriteria" minOccurs="0" xdb:SQLName="EVALUATIONCRITERIA"/>
70 <xs:element name="postBaccDegreeInfo" minOccurs="0" xdb:SQLName="POSTBACCDEGREEINFO"/>
71 <xs:element name="postBaccCertificateInfo" minOccurs="0" xdb:SQLName="POSTBACCCERTIFICATEINFO"/>
72 <xs:element name="advancedPlacement" minOccurs="0" xdb:SQLName="ADVANCEDPLACEMENT"/>
73 <xs:element name="graduation" minOccurs="0" xdb:SQLName="GRADUATION"/>
74 <xs:element name="curriculum" minOccurs="0" xdb:SQLName="CURRICULUM"/>
75 <xs:element name="listOfCourse" type="ap:ListOfCourseType" minOccurs="0" xdb:SQLName="LISTOFCOURSE"/>
76 </xs:sequence>
77 </xs:complexType>
78 </xs:schema>
79 ');
80 begin
81 if (dbms_xdb.existsResource(:schemaPath)) then
82 dbms_xdb.deleteResource(:schemaPath);
83 end if;
84 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
85 end;
86 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> insert into COURSE values ( xmltype(
2 '<?xml version="1.0" encoding="WINDOWS-1252"?>
3 <?altova_sps http://aahmb10-147:7575/public/www.mdanderson.org/template/APEP/courseInput.sps?>
4 <course xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb=
"http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/schema/APE
P/courseCatalog http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd">
5 <id>53</id>
6 <compositeID>
7 <prefix>CL</prefix>
8 <level>4</level>
9 <creditHours>1</creditHours>
10 <identNumber>05</identNumber>
11 </compositeID>
12 <title>Urinalysis </title>
13 <description>A review of the anatomy and physiology of the kidney and the formation, elimination, and composition of urine and body flu
ids. Interpretation of urinary elements, chemical assays, and the correlation with normal and abnormal physiology.</description>
14 </course>'))
15 /
1 row created.
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
SQL> insert into COURSE values ( xmltype(
2 '<?xml version="1.0" encoding="WINDOWS-1252"?>
3 <?altova_sps http://aahmb10-147:7575/public/www.mdanderson.org/template/APEP/courseInput.sps?>
4 <course xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb=
"http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/schema/APE
P/courseCatalog http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd">
5 <id>54</id>
6 <compositeID>
7 <prefix>CL</prefix>
8 <level>4</level>
9 <creditHours>1</creditHours>
10 <identNumber>05</identNumber>
11 </compositeID>
12 <title>Course 54</title>
13 <description>A review of the anatomy and physiology of the kidney and the formation, elimination, and composition of urine and body flu
ids. Interpretation of urinary elements, chemical assays, and the correlation with normal and abnormal physiology.</description>
14 </course>'))
15 /
1 row created.
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
SQL> insert into COURSE values ( xmltype(
2 '<?xml version="1.0" encoding="WINDOWS-1252"?>
3 <?altova_sps http://aahmb10-147:7575/public/www.mdanderson.org/template/APEP/courseInput.sps?>
4 <course xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb=
"http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/schema/APE
P/courseCatalog http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd">
5 <id>55</id>
6 <compositeID>
7 <prefix>CL</prefix>
8 <level>4</level>
9 <creditHours>1</creditHours>
10 <identNumber>05</identNumber>
11 </compositeID>
12 <title>Course 55</title>
13 <description>A review of the anatomy and physiology of the kidney and the formation, elimination, and composition of urine and body flu
ids. Interpretation of urinary elements, chemical assays, and the correlation with normal and abnormal physiology.</description>
14 </course>'))
15 /
1 row created.
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
SQL> insert into ACADEMICPROGRAM values ( xmltype (
2 '<?xml version="1.0" encoding="WINDOWS-1252"?>
3 <!--Sample XML file generated by XMLSpy v2006 rel. 3 U (http://www.altova.com)-->
4 <academicProgram xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" x
mlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/s
chema/APEP/courseCatalog http://aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/academicProgram.xsd">
5 <name>Clinical Laboratory Science</name>
6 <description>The clinical laboratory scientist is an essential member of the health care team, performing a myriad of laboratory proc
edures aimed at the diagnosis and treatment of disease.</description>
7 <listOfAcademicCredential>
8 <credential>
9 <id>0</id>
10 <field>String</field>
11 <typeCode>Bachelor of Science Degree</typeCode>
12 </credential>
13 <credential>
14 <id>0</id>
15 <field>String</field>
16 <typeCode>Bachelor of Science Degree</typeCode>
17 </credential>
18 <credential>
19 <id>0</id>
20 <field>String</field>
21 <typeCode>Bachelor of Science Degree</typeCode>
22 </credential>
23 </listOfAcademicCredential>
24 <listOfRelatedParty xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
25 <mission>String</mission>
26 <goals>String</goals>
27 <objectives>String</objectives>
28 <competencies xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
29 <selectionProcess xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
30 <listOfRequirement>
31 <requirement>
32 <typeCode>String</typeCode>
33 <description>String</description>
34 <scope>String</scope>
35 </requirement>
36 </listOfRequirement>
37 <evaluationCriteria xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
38 <postBaccDegreeInfo xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
39 <postBaccCertificateInfo xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
40 <advancedPlacement xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
41 <graduation xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
42 <curriculum xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
43 <listOfCourse>
44 <id>53</id>
45 <course>
46 <id>53</id>
47 <compositeID>
48 <prefix>CL</prefix>
49 <level>4</level>
50 <creditHours>1</creditHours>
51 <identNumber>05</identNumber>
52 </compositeID>
53 <title>Biochemistry</title>
54 <description>this is a test for the course biochemistry</description>
55 </course>
56 <course>
57 <id>55</id>
58 <compositeID>
59 <prefix>CL</prefix>
60 <level>4</level>
61 <creditHours>1</creditHours>
62 <identNumber>05</identNumber>
63 </compositeID>
64 <title>Something Else</title>
65 <description>this is a test for the course biochemistry</description>
66 </course>
67 </listOfCourse>
68 </academicProgram>'))
69 /
1 row created.
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
SQL> select extractValue(value(c),'/course/id')
2 from ACADEMICPROGRAM ap,
3 table (xmlsequence(extract(value(ap),'/academicProgram/listOfCourse/course','xmlns="http://www.mdanderson.org/schema/APEP/courseCatalo
g"'))) c
4 /
53
55
Execution Plan
Plan hash value: 3351541143
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 126 | 804 (0)| 00:00:10 |
| 1 | NESTED LOOPS | | 2 | 126 | 804 (0)| 00:00:10 |
|* 2 | INDEX FAST FULL SCAN | SYS_IOT_TOP_177341 | 2 | 66 | 802 (0)| 00:00:10 |
|* 3 | TABLE ACCESS BY INDEX ROWID| ACADEMICPROGRAM | 1 | 30 | 1 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | SYS_C0022632 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("SYS_NC_TYPEID$" IS NOT NULL)
3 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-ins
tance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-properti
es/><read-contents/></privilege>'))=1)
4 - access("NESTED_TABLE_ID"="ACADEMICPROGRAM"."SYS_NC0004200043$")
Note
- dynamic sampling used for this statement
SQL> select updateXML
2 (
3 ap.object_value,
4 '/academicProgram/listOfCourse',
5 ( select xmlelement
6 (
7 "listOfCourse",
8 xmlattributes('http://www.mdanderson.org/schema/APEP/courseCatalog' as "xmlns"),
9 ( select xmlagg ( xmlconcat(extract(object_value,'/course/id'), extract(object_value,'/course')) )
10 from course c,
11 table (xmlsequence(extract(ap.object_value,'/academicProgram/listOfCourse/course','xmlns="http://www.mdanders
on.org/schema/APEP/courseCatalog"'))) api
12 where extractValue(c.object_value,'/course/id') = extractValue(value(api),'/course/id')
13 )
14 ) from dual
15 ),
16 'xmlns:="http://www.mdanderson.org/schema/APEP/courseCatalog"'
17 )
18 from ACADEMICPROGRAM ap
19 /
<?xml version="1.0" encoding="WINDOWS-1252"?>
<!--Sample XML file generated by XMLSpy v2006 rel. 3 U (http://www.altova.com)--><academicProgram xmlns="http://www.mdanderson.org/schema/AP
EP/courseC
atalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/X
MLSchema-i
nstance" xsi:schemaLocation="http://www.mdanderson.org/schema/APEP/courseCatalog http://aahmb10-147:7575/public/www.mdanderson.org/schema/AP
EP/academi
cProgram.xsd">
<name>Clinical Laboratory Science</name>
<description>The clinical laboratory scientist is an essential member of the health care team, performing a myriad of laboratory procedure
s aimed at
the diagnosis and treatment of disease.</description>
<listOfAcademicCredential>
<credential>
<id>0</id>
<field>String</field>
<typeCode>Bachelor of Science Degree</typeCode>
</credential>
<credential>
<id>0</id>
<field>String</field>
<typeCode>Bachelor of Science Degree</typeCode>
</credential>
<credential>
<id>0</id>
<field>String</field>
<typeCode>Bachelor of Science Degree</typeCode>
</credential>
</listOfAcademicCredential>
<listOfRelatedParty xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<mission>String</mission>
<goals>String</goals>
<objectives>String</objectives>
<competencies xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<selectionProcess xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<listOfRequirement>
<requirement>
<typeCode>String</typeCode>
<description>String</description>
<scope>String</scope>
</requirement>
</listOfRequirement>
<evaluationCriteria xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<postBaccDegreeInfo xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<postBaccCertificateInfo xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<advancedPlacement xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<graduation xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<curriculum xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog"/>
<listOfCourse xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog">
<id xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog">53</id>
<course xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb="
http://xml
ns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/schema/APEP/courseCat
alog http:
//aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd">
<id>53</id>
<compositeID>
<prefix>CL</prefix>
<level>4</level>
<creditHours>1</creditHours>
<identNumber>05</identNumber>
</compositeID>
<title>Urinalysis </title>
<description>A review of the anatomy and physiology of the kidney and the formation, elimination, and composition of urine and body fl
uids. Inte
rpretation of urinary elements, chemical assays, and the correlation with normal and abnormal physiology.</description>
</course>
<id xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog">55</id>
<course xmlns="http://www.mdanderson.org/schema/APEP/courseCatalog" xmlns:ns1="http://www.mdanderson.org/schema/APEP/custom" xmlns:xdb="
http://xml
ns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mdanderson.org/schema/APEP/courseCat
alog http:
//aahmb10-147:7575/public/www.mdanderson.org/schema/APEP/courseCatalog.xsd">
<id>55</id>
<compositeID>
<prefix>CL</prefix>
<level>4</level>
<creditHours>1</creditHours>
<identNumber>05</identNumber>
</compositeID>
<title>Course 55</title>
<description>A review of the anatomy and physiology of the kidney and the formation, elimination, and composition of urine and body fl
uids. Inte
rpretation of urinary elements, chemical assays, and the correlation with normal and abnormal physiology.</description>
</course>
</listOfCourse>
</academicProgram>
Execution Plan
Plan hash value: 1698158615
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 47932 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13818 | | |
|* 2 | HASH JOIN | | 1 | 13818 | 5 (20)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | SYS_IOT_TOP_177341 | 1 | 33 | 2 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| COURSE | 3 | 41355 | 3 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 6 | TABLE ACCESS FULL | ACADEMICPROGRAM | 1 | 47932 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("COURSE"."SYS_NC00009$"="ID")
3 - access("NESTED_TABLE_ID"=:B1)
filter("SYS_NC_TYPEID$" IS NOT NULL)
4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read
-properties/><read-contents/></privilege>'))=1)
6 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read
-properties/><read-contents/></privilege>'))=1)
Note
- dynamic sampling used for this statement
SQL> -
Joining two fact tables with different dimensions into single logical table
Hi Gurus,
I try to accomplish in Oracle Business Intelligence 11.1.1.3.0:
F1 (D1, D2 and D3)
F2 (D1 and D2 and D4)
And we want to build a report F1 F2 D1 D2 D3 D4 to have data for:
F1 that match only for D1-D2-D3
and data for
F2 that match only D1-D2-D4
all that in one row, so D3 and D4 are not common dimensions.
I can only do:
F3 (D1, D2)
F4 (D1, D2 and D4)
And report
F3 F4 D1,D2,D4 (all that in one row, and only D4 is not a common dimension)
Here is the very good example how to accomplish the scenario 1
http://108obiee.blogspot.com/2009/08/joining-two-fact-tables-with-different.html
But looks like it does not work in 11.1.1.3.0
I get
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 14025] No fact table exists at the requested level of detail: [,,Clients,,Day,ROI,,,,EW_Names,,,,,,,,,,,,,,,,,]. (HY000)
I am sure I set up everything correctly as advised in the blog but it works with only one not a common dimension
Is it a bug in 11.1.1.3.0 or something?
Thanks,
KateThanks for all your replies.
Actually, I've tried the solutions you guys mentioned. Generally speaking, the result should be displayed. However, my scenario is a little bit tricky.
table Y's figures are not the aggregation of table X for D dimension. Instead, table Y's figures include not only D dimension total, but also others (others do not mean A, B, C dimension). For example, table Y stores all food's figure, while table X stores only drink's figure. D dimension is only about drink's detail. In my scenario, other foods' figure is not provided.
So, even if I set D dimension to all/total for table X, table X's result is still not the same as table Y.
Indeed, table Y does not have a column key to join to D dimension's key. So, if I select D dimension and table Y's measures at the same time in BI Answer, result returns no data. Hence, I can't compare table X and table Y's results with selection of D dimension.
Is there any solution to solve this problem?
Edited by: TomChan on Jun 3, 2009 9:36 AM -
Can we join two totals tables in ABAP Query
Hey Gurus!
Can we join two totals tables in ABAP query.
I am tyring to join FAGFLEXT with internal orders totals table.
Thanks
SHi,
Report painter majorily operates around characteristics and key figures.
ABAP query comes even more handy. The advantage is -
1. You can link many tables
2. Create selection screen as you like to have
3. User friendly report creation
4. Logic can also be coded.
5. Authorization can be set
I have written a article in SDN, which gives you an idea as to how to go about using ABAP query. Have a look on this - [Article - Practical Usage of ABAP Query|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f6b256-23be-2b10-8b93-cad83a617634]
Regards,
Sridevi -
How to join two internal table rows in alternative manner into one internal table?
How to join two internal table rows in alternative manner into one internal table?
two internal tables are suppose itab1 & itab2 & its data
Header 1
Header 2
Header 3
a
b
c
d
e
f
g
h
i
Header 1
Header 2
Header 3
1
2
3
4
5
6
7
8
9
INTO itab3 data
Header 1
Header 2
Header 3
a
b
c
1
2
3
d
e
f
4
5
6
g
h
i
7
8
9Hi Soubhik,
I have added two additional columns for each internal table.
Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
Row_Count - It represents the Row Count Number, increase the row count value 1 by one..
ITAB1:
Header 1
Header 2
Header 3
Table_Count
Row_Count
a
b
c
1
1
d
e
f
1
2
g
h
i
1
3
ITAB2:
Header 1
Header 2
Header 3
Table_Count
Row_Count
1
2
3
2
1
4
5
6
2
2
7
8
9
2
3
Create the Final Internal table as same as the ITAB1/ITAB2 structure.
"Data Declarations
DATA: IT_FINAL LIKE TABLE OF ITAB1. "Final Internal Table
FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1, "TAB1
<FS_TAB2> TYPE TY_TAB2. "TAB2
"Assign the values for the additional two column for ITAB1
LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
<FS_TAB1>-TABLE_COUNT = 1. "Table value same for all row
<FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Assign the values for the additional two column for ITAB2
LOOP AT ITAB2 ASSIGNING <FS_TAB2>.
<FS_TAB2>-TABLE_COUNT = 2. "Table value same for all row
<FS_TAB2>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Copy the First Internal Table 'ITAB1' to Final Table
IT_FINAL[] = ITAB1[].
"Copy the Second Internal Table 'ITAB2' to Final Table
APPEND IT
LOOP AT ITAB2 INTO WA_TAB2.
APPEND WA_TAB2 TO IT_FINAL.
ENDLOOP.
"Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
SORT IT_FINAL BY ROW_COUNT TABLE_COUNT.
After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
Regards
Rajkumar Narasimman -
Spatial Tables and Remote Queries
Hi Experts,
Can anyone explain me when and where to use Spatial Tables and Remote Queries with some examples.
Thanks in advance.Hi,
there are some nice demos from Andrejus:
http://andrejusb.blogspot.com/search/label/Spatial
Hope it helps,
Friedhold -
Inner join on Buffred table and not buffered table.
Hi guys,
Can you suggest me how can i write select query using inner join on buffered table and not buffered table. i written like this. is it right?
SELECT a~vbeln
a~vkorg
a~kunnr
a~kunag
a~wadat_ist
a~xblnr
b~bukrs
FROM likp AS a INNER JOIN tvko AS b
ON avkorg = bvkorg BYPASSING BUFFER
INTO TABLE itab_likp
WHERE vbeln = s_vbeln.
Thanks.
RAJHi Raj ,
Please find below my Commentes :
1. When you use "Bypassing buffer" clause in Select statement , the data what is there in the buffer of application sever is always ignored and Read is performed from the Physical database always. This Clause is advisable where you require realtime data (Not recommended generally in reporting)
2. It is advisable that you should not use small table in the innerjoin with big table. In the query you have written there are 2 tables:- LIKP and TVKO outof which TVKO is a master table containing very few records than LIKP (Contains huge data for Delivery header).
So my recommendation will be : -
1. Eliminate the "Bypassing Buffer" clause from your Query
2. Break the select query into 2 select queries breaking the join and with some ABAP logic populate the Internal table "itab_likp".
This will be optimum way inwhich you can write the select query for your senarion. Also Ensure that indexes are being used for better selectivity.
Hope this will help to you.
Regards,
Nikhil -
To compare two internal tables and delete records
Hi friends,
I have to compare two internal tables and should delete the records which is not present in both the tables. Reply me as soon as possible.
Thanks.Hi Nagarajan,
1. I don't think there is any direct (one-shot statement)
way to achieve this.
one has to do by writing some logic.
2. Loop at ITAB1.
Read table ITAB2 with key Field1 = ITAB1-Field1.
If sy-subrc <> 0.
delete ITAB1.
endif.
Endloop.
Do the same again with ITAB2.
Loop at ITAB2.
Read table ITAB1 with key Field1 = ITAB2-Field1.
If sy-subrc <> 0.
delete ITAB2.
endif.
Endloop.
3. If any better way is found, i will let u know.
Hope it helps.
Regards,
Amit M. -
Location of spatial tables and warehouse tables - recommendations
Hi all,
I have a question from a customer who's asking what the recommendation is of storage of the spatial tables and the warehouse tables.
Should they reside on the same database for best performance or doesn't it matter where the spatial tables are located.
Is there any official recommednation from Oracle on this?
Best regards,
HakanHello Mohan ,
Table TOBJ store the authorization data in R/3 System .
For further info refer thread :
What does TOBJ table contain??
Regards ,
Santosh -
Problem encountered when join two remote tables in a materialized view
I'm using oracle 9.2.0.6
1> I have two tables:
CREATE TABLE TEST
A VARCHAR2(100 BYTE),
C DATE
CREATE TABLE TEST1
A VARCHAR2(100 BYTE),
B TIMESTAMP
2>. I defined a prebuild table:
CREATE TABLE MV_TEST1
ID1 ROWID,
A VARCHAR2(100 BYTE),
ID2 ROWID,
B TIMESTAMP(6),
C DATE
3> I created mview logs:
CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST
WITH ROWID
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST1
WITH ROWID
INCLUDING NEW VALUES;
4> when I create mview:
CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
ON PREBUILT TABLE WITH REDUCED PRECISION
REFRESH FAST ON DEMAND
WITH PRIMARY KEY
AS
select
test.rowid id1,
test.a,
test1.rowid id2,
test1.b,
cast(null as date) c
from test , test1
where test.a = test1.a(+);
It is created successfully.
5> problem:
when I use remote tables to do the same thing, say test and test1 are in another instance and are connected by a dbLink, I couldn't create the mview successfully:
CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
ON PREBUILT TABLE WITH REDUCED PRECISION
REFRESH FAST ON DEMAND
WITH PRIMARY KEY
AS
select
a.rowid id1,
a.a,
b.rowid id2,
b.b,
cast(null as date) c
from test@dbl a, test1@dbl b
where a.a = b.a(+);
when run above statement, I got:
ORA-12015: cannot create a fast refresh materialized view from a complex query
Any ideas? Or joining two table through a dblink for a mview is not allowed at all?
Thanks in advance.No one has a clue?
Message was edited by:
lzhwxy -
Hi,
I have two fact tables F1 and F2 joined with few dimensions D1.....D9. D1,D2 and D3 are conformed dimensions.
In Physical:
F1>--D1,D2,D3,D4,D5,D6
F2>--D1,D2,D3,D7,D8,D9
In Logical:
F1>--D1,D2,D3,D4,D5,D6
F2>--D1,D2,D3,D7,D8,D9
there are some ports already using above star schemas. now I got new requirements and I need to use measures from both the fact tables and conformed and unconformed dimensions.
I did the following in logical
F1 LTS GENERAL TAB ADDED F2,D1,D2,D3,D7,D8,D9 and in content tab set logical level to unconformed dimensions at total level and for conformed dimensios at details level.
F2 LTS GENERAL TAB ADDED F1,D1,D2,D3,D7,D8,D9 and in content tab set logical level to unconformed dimensions at total level and for conformed dimensios at details level.
but I'm still getting
[nQSError: 14026] Unable to navigate requested expression:
Please fix the metadata consistency warnings. (HY000)
I cheked metadata global consistency and no errors found.
Appreciate your help
Thanks
Jay.
Edited by: Jay on Sep 27, 2011 10:14 AM
Edited by: Jay on Sep 27, 2011 10:15 AMLet me explain my issue again
In Physical:
F1>--D1,D2,D3,D4,D5,D6
F2>--D1,D7
In Logical: Single logical fact Fact_FY_Ratio has two logical sources
LTS1: F1>--D1,D2,D3,D4,D5,D6
LTS2: F2>--D1,D7
Set the content level for each LTS in Fact_FY_Ratio:
F1 to Detail for D1,D2,D3,D4,D5,D6 and to Total for D7
F2 to Detail for D1,D7 and to Total for D2,D3,D4,D5,D6
In LTS 1 general tab added inner joins with all dimensions F1,D1,D2,D3,D4,D5,D6,D7and F2
In LTS 2 general tab added inner joins with all dimensions F2,D1,D7,D2,D3,D4,D5,D6 and F1
And I also did logical complex join for Fact_FY_Ratio with all logical dimensions D1,D2,D3,D4,D5,D6,D7
I'm able to run query using D1,D2,D3,D4,D5,D7,F1,F2 but when I include D6(time dimension) it is causing problem with F2(witth F1 it is working fine).
query success with:
F1,D1,D2,D3,D4,D5,D6
F2,D1,D7
D1,D2,D3,D4,D5,D7,F1,F2
Query failed with:
F2>--D1,D7 and D6
Please let me know anything wrong with above configuration.
Thanks
Jay...
Edited by: Jay on Oct 3, 2011 7:11 AM -
Join multiple fact tables and dimensions and use all tables in report issue
Hi,
I have a report requirements and need to use multiple fact tables and unconformed dimensions as described below
Fact table: F1,F2,F3
Dimensions tables: D1.....D9
F1:(joined to) D1,D2,D3,D4
F2::(joined to)D1,D2,D5,D6
F3::(joined to)D1,D2,D7,D8
D7::(joined to)D9,D8 (dimension D7 joined to two other dimensions D9 and D8
I'm trying to use columns from almost all the fact and dimension tables but getting "Unable to navigate requested expression. Please fix the metadata consistency warnings."
Repository is consistent and no errors and warnings.
How can I configure the repository to develop reports using all fact tables and dimensions?
Appreciate for your help.
Thanks
Jay.
Edited by: Jay on Feb 9, 2012 4:14 PMSo you want me to convert snowflake schema to star. does it solve my problem? individual star queries are working find but when I query multiple stars together getting inconsistency errors. I removed content tables dim level totals for unconformed dimensions in logical fact LTS and set level for measures at total level for unconformed dimensions. it is still in progress and need to test.
Thanks
Jay.
Maybe you are looking for
-
How can i open files, instead of having them just save. there was a option with save or open, and normally i open but i clicked save and i have tried several ways to fix it, none of them work. any and all help would be nice == This happened == Every
-
FLV runs on local, but not on server using CS4
I have run the insert FLV as a progressive download and it works correctly on live view. Once loaded on the server, it does not work. http://www.transworldincelectric.com/test.html I have a folder called Scripts loaded to the server and it contains t
-
Anyone know of a tool for auto generate EJB from DB
Does anyone know of a tool that connects to a DB and auto generates EJBs from the table schema, either CMP or BMP. Perhaps allowing you some control over choosing the table, pk, etc. THANKS
-
Insufficient disk space remaining in the capture scratch
I'm using a PowerBook G4, 1.25GHz processor with 2 GB DDR SDRAM whit Final Cut Express version 3.5.1. I tried to capture footage from my camera and received a message, "insufficient disk space remaining in the capture scratch." I moved all the files:
-
I got a new iMac and my keyboard is not pairing to the iMac. The Keyboard came with the computer.