Creation of view with clob column in select and group by clause.
Hi,
We are trying to migrate a view from sql server2005 to oracle 10g. It has clob column which is used in group by clause. How can the same be achived in oracle 10g.
Below is the sql statament used in creating view aling with its datatypes.
CREATE OR REPLACE FORCE VIEW "TEST" ("CONTENT_ID", "TITLE", "KEYWORDS", "CONTENT", "ISPOPUP", "CREATED", "SEARCHSTARTDATE", "SEARCHENDDATE", "HITS", "TYPE", "CREATEDBY", "UPDATED", "ISDISPLAYED", "UPDATEDBY", "AVERAGERATING", "VOTES") AS
SELECT content_ec.content_id,
content_ec.title,
content_ec.keywords,
content_ec.content content ,
content_ec.ispopup,
content_ec.created,
content_ec.searchstartdate,
content_ec.searchenddate,
COUNT(contenttracker_ec.contenttracker_id) hits,
contenttypes_ec.type,
users_ec_1.username createdby,
Backup_Latest.created updated,
Backup_Latest.isdisplayed,
users_ec_1.username updatedby,
guideratings.averagerating,
guideratings.votes
FROM users_ec users_ec_1
JOIN Backup_Latest
ON users_ec_1.USER_ID = Backup_Latest.USER_ID
RIGHT JOIN content_ec
JOIN contenttypes_ec
ON content_ec.contenttype_id = contenttypes_ec.contenttype_id
ON Backup_Latest.content_id = content_ec.content_id
LEFT JOIN guideratings
ON content_ec.content_id = guideratings.content_id
LEFT JOIN contenttracker_ec
ON content_ec.content_id = contenttracker_ec.content_id
LEFT JOIN users_ec users_ec_2
ON content_ec.user_id = users_ec_2.USER_ID
GROUP BY content_ec.content_id,
content_ec.title,
content_ec.keywords,
to_char(content_ec.content) ,
content_ec.ispopup,
content_ec.created,
content_ec.searchstartdate,
content_ec.searchenddate,
contenttypes_ec.type,
users_ec_1.username,
Backup_Latest.created,
Backup_Latest.isdisplayed,
users_ec_1.username,
guideratings.averagerating,
guideratings.votes;
Column Name Data TYpe
CONTENT_ID NUMBER(10,0)
TITLE VARCHAR2(50)
KEYWORDS VARCHAR2(100)
CONTENT CLOB
ISPOPUP NUMBER(1,0)
CREATED TIMESTAMP(6)
SEARCHSTARTDATE TIMESTAMP(6)
SEARCHENDDATE TIMESTAMP(6)
HITS NUMBER
TYPE VARCHAR2(50)
CREATEDBY VARCHAR2(20)
UPDATED TIMESTAMP(6)
ISDISPLAYED NUMBER(1,0)
UPDATEDBY VARCHAR2(20)
AVERAGERATING NUMBER
VOTES NUMBERAny help realyy appreciated.
Thanks in advance
Edited by: user512743 on Dec 10, 2008 10:46 PM
Hello,
Specifically, this should be asked in the
ASP.Net MVC forum on forums.asp.net.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})
Similar Messages
-
Exporting Table with CLOB Columns
Hello All,
I am trying to export table with clob columns with no luck. It errors saying EXP-00011TABLE do not exist.
I can query the table and the owner is same as what i am exporting it from.
Please let me know.An 8.0.6 client definitely changes things. Other posters have already posted links to information on what versions of exp and imp can be used to move data between versions.
I will just add that if you were using a client to do the export then if the client version is less than the target database version you can upgrade the client or better yet if possilbe use the target database export utility to perform the export.
I will not criticize the existance of an 8.0.6 system as we had a parent company dump a brand new 8.0.3 application on us less than two years ago. We have since been allowed to update the database and pro*c modules to 9.2.0.6.
If the target database is really 8.0.3 then I suggest you consider using dbms_metadata to generate the DDL, if needed, and SQLPlus to extact the data into delimited files that you can then reload via sqlldr. This would allow you to move the data with some potential adjustments for any 10g only features in the code.
HTH -- Mark D Powell -- -
Partition Name in Select and Group-By
Is there a function that returns the partition name a row is stored in? I'd like to use it in a SELECT statement, if it exists.
The goal is to get row counts per partition to determine skew on a hash-based partition (otherwise, I'd just select and group-by the partition key). I want to do something like this:
SELECT PARTITION_NAME, COUNT(*) as PER_PART_COUNT
FROM SOMETABLE
GROUP BY PARTITION_NAME;Obviously, I would replace the string "*PARTITION_NAME*" with whatever function returns that value.
NOTE: Before the forum sharks jump all over me, I did search the documentation and forums, but I came up empty handed.Hi,
This is hokey - but you can use the undocumented function "tbl$or$idx$part$num" like so:
SELECT atp.partition_name
, COUNT (*) AS count_rows
FROM all_tab_partitions atp
, (SELECT tbl$or$idx$part$num ("SCOTT"."TAB1"
, 0
, 1
, 0
, partition_col1 -- your 1st partition key column
, partition_col2 -- your 2nd partition key column
) AS part_num
, 'TAB1' AS table_name
, 'SCOTT' AS owner
FROM scott.tab1) pt
WHERE atp.table_name = pt.table_name
AND atp.table_owner = pt.owner
AND atp.partition_position = pt.part_num
GROUP BY atp.partition_name;Note - this probably won't perform well at all... but it could be an option...
Message was edited by:
PDaddy
... On 2nd thought - don't do it - it seems it is pretty unstable - brought my session to a halt a couple of times... Forget I mentioned it :)
... On 3rd thought - if you add ROWNUM - it works fine - seems you need to materialize the result set in the inner query - like so:
CREATE TABLE part_tab (part_key int
, a int
partition by range (part_key)
(partition p1 values less than (100)
,partition p2 values less than (200)
,partition p3 values less than (maxvalue)
insert into part_tab
select rownum
, rownum
FROM all_objects
where rownum <= 1000; SELECT atp.partition_name
, COUNT(*) AS count_rows
FROM all_tab_partitions atp
, (SELECT TBL$OR$IDX$PART$NUM("PART_TAB", 0, 1, 0, part_key) AS part_num
, 'PART_TAB' AS table_name
, user AS owner
, ROWNUM AS rn -- Materialize the result set by adding ROWNUM...
FROM part_tab) pt
WHERE atp.table_name = pt.table_name
AND atp.table_owner = pt.owner
AND atp.partition_position = pt.part_num
GROUP BY atp.partition_name; -
Instead of trigger on view with CLOB data
I have writed Instead of trigger for view "article(id,text)" with CLOB
field "text".
create or replace trigger v_article_insert
instead of insert on v_article
for each row
declare
begin
insert into article(id,text) values(id,:new.text);
end v_article_insert;
When I try to do DML (insert, update), forexample:
insert into v_article(text) values('bla-bla')
I get:
ORA-25008 no implicit conversion to LOB datatype in instead-of trigger.
( Cause: When inserting or updating a view using instead-of trigger, the
new value for a LOB view column is of a different datatype.
Action: Specified a LOB value as the new value for the LOB view
column.)
insert into v_article(text) values(empty_clob()) - It works...
What does it mean and what is right syntax for DML for CLOB fields in
instead of triggers?When inserting CLOBs you create the row with an Empty_Clob() to initialize the CLOB field. Then you can update the empty CLOB with your CLOB value.
The error message is telling you that Oracle will not convert your CLOB to the initialization value needed. -
Create materialized view with specific column sizes
Hi all,
I'm trying to create a materialized view with a specific a column size. Something like
create materialized view test_mv
refresh force on demand
as
select id,
cast(my_compound_field as nvarchar2(50))
from ( select id,
field1 || field2 my_compound_field
from my_table);But Oracle seems to ignore the cast and takes the maximum size it finds for field1 || field2 in the select query. The resulting table has a column nvarchar2(44) instead of nvarchar2(50).
This can give a problem when the view is refreshed... there could be new data that exceeds the current size, i.e. where length(field1 || field2) > 44.
How can I override the column size of a field in a materialized view?
Edit: Some additional info to clarify my case:
field1 and field2 are defined as nvarchar2(25). field1 || field2 can theoretically have a length of 50, but there is currently no data in my table that results in that length, the max is 44. I am afraid that there will be data in the future that exceeds 44, resulting in an error when the MV is refreshed!
Edited by: Pleiadian on Jan 25, 2011 2:06 PMCannot reproduce what you are saying is happening.
SQL> create table t (a nvarchar2(50), b nvarchar2(50));
Table created.
SQL> create materialized view tmv as
2 select a, b, a || b c from t;
Materialized view created.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(100)
SQL> drop materialized view tmv;
Materialized view dropped.
SQL> create materialized view tmv as
2 select a, b, substr(a || b, 1, 10) c from t;
Materialized view created.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(10)
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL>Edited by: 3360 on Jan 25, 2011 8:10 AM
And with data
SQL> insert into t values ('3123423423143hhshgvcdcvw', 'ydgeew gdfwe dfefde wfjjjjjjj');
1 row created.
SQL> commit;
Commit complete.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(10)
SQL> select * from tmv;
A
B C
3123423423143hhshgvcdcvw
ydgeew gdfwe dfefde wfjjjjjjj 3123423423 -
How To Create Table View With Same Column name But Different Table?
Hi All,
I have the problem to create a tableview with same column name but in different table.
The Table that i have:-
Table - PAC051MPROFORMA
Column - mrn,visitid
Table - PAC051TPROFORMA
Column - mrn,visitid
Table - PAC052MTRANSBILL
Column - mrn,visitid
Then i want to create a table view to view that table. This is my SQL
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
That SQL Return this error = ORA-00957: duplicate column name
Then I modify that SQL to
CREATE VIEW pacviewproforma (mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
This time this error return = ORA-01730: invalid number of column names specified
What should i do?
Thanks...Hi,
SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
ERROR at line 1:
ORA-00957: duplicate column namePlease give different names to each column.
Something like this..
SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
_visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
View created.
SQL> DESC pacviewproforma;
Name Null? Type
MPROFORMA_MRN NUMBER
MPROFORMA_VISITID NUMBER
TPROFORMA_MRN NUMBER
TPROFORMA_VISITID NUMBER
MTRANSBILL_MRN NUMBER
MTRANSBILL_VISITID NUMBER
ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
Twinkle -
View with renamed column does not use index
Is there any reason why a view that renames the columns presented to the users would ignore an index?
For example:
CREATE OR REPLACE VIEW ENROLLMENT
(ENROLLMENT_ID, ENROLLMENT_DATE, FIRST_NAME)
AS
select distinct
a.col1 as enrollment_id,
a.col2 as enrollment_date,
a.col3 as first_name
from t1 a
When a user queries the view, with a WHERE FIRST_NAME = 'TOM", it results in a FTS. However, if you run the query against the base table (using col1, col2, and col3), it uses the index against t1 on (col3, col2, col1).Well, I tried to create the supporting evidence afterwards (sigh, why do I keep doing that ...), it seems that Oracle has addressed this problem already:
SQL> create table t1
2 as
3 select l col1, sysdate - l/86400 col2, decode(l,1,'TOM',to_char(l)) col3
4 from (select level l from dual connect by level <= 100000)
5 /
Tabel is aangemaakt.
SQL> create index i1 on t1 (col3, col2, col1)
2 /
Index is aangemaakt.
SQL> exec dbms_stats.gather_table_stats(user,'T1',method_opt=>'FOR ALL INDEXED COLUMNS')
PL/SQL-procedure is geslaagd.
SQL> create view enrollment
2 (enrollment_id, enrollment_date, first_name)
3 as
4 select distinct
5 a.col1 as enrollment_id,
6 a.col2 as enrollment_date,
7 a.col3 as first_name
8 from t1 a
9 /
View is aangemaakt.
SQL> set autotrace on explain
SQL> select * from enrollment where first_name = 'TOM'
2 /
ENROLLMENT_ID ENROLLMENT_DATE FIRST_NAME
1 16-01-2007 14:41:25 TOM
1 rij is geselecteerd.
Uitvoeringspan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=44)
1 0 VIEW OF 'ENROLLMENT' (Cost=3 Card=1 Bytes=44)
2 1 SORT (UNIQUE NOSORT) (Cost=3 Card=1 Bytes=18)
3 2 INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=3 Card=1
Bytes=18)I'm on 9.2.0.7.0 here, what's your version ?
Regards,
Rob. -
How to create a view with a column of counts of the occurence of values
If my table is:
ID
1
2
3
3
5
5
5
I want to create a view with the following result:
ID COUNT
1 1
2 1
3 2
5 3
How would I accomplish this?Sorry, my mistake. I was thinking about counting distinct events.
I created a table with your example values:
You should do a projection with a calculated column = 1:
And then add this calculated column as an aggregated measure on the aggregation node:
Result:
Cheers,
Fernando -
This is reports 11g
I've got a clob column. Reports seems to recognize its type, but if I try to reference it in a format trigger, I get this error at compile time:
"No pl/sql translation for the blind type given for this bind variable"Actually, Reports is in something better than Forms.
Neither Forms nor Reports do not have "complete" SQL engine (both have only "complete" PL/SQL engine), but have their own SQL parser, which does not understand SQL commands after the database 8.0.
But, in Reports Data Model - SQL Query Statement, we can write "modern" SQL statement (> database 8.0), because Reports sent it directly to the database, without using their own SQL parser.
For example, in Reports Data Model - SQL Query Statement, we can write this (scalar subquery expressions, in bold):
select empno,
ename,
deptno,
(select dname from dept where deptno = emp.deptno) dname
from emp
order by empno;
although scalar subquery expressions was introduced in the database 9.0.1, and in databases 8.0 and 8.1 we should write someting like this:
select emp.empno,
emp.ename,
emp.deptno,
dept.dname
from emp,
dept
where dept.deptno = emp.deptno
order by empno;
Regards,
Zlatko -
Can clob columns be selected across a database link (synonym)?
Hello,
I would like to do something like this...
insert into archive_table (id, msg, start_date)
select id, msg, startdate from synonym_table
where start_date < whatever;
...where msg represents a clob column and synonym_table represents a synonym in the current table space which accesses another Oracle table using a database link.
Is this possible?http://asktom.oracle.com/pls/ask/f?p=4950:8:15261108079829288196::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:950029833940
-
Export data from table with CLOB column
DB: Oracle10g
SQLDeveloper: 1.0
OS: windows xp for sqldeveloper
Linux for Oracle db
we have a table with two CLOB columns. We want to export the data to either text or csv. But the CLOB columns don't show up in the columns that can be exported.
How do I export CLOB data from SQL Developer?
Regards,
LonnekeI don't think this is a good protection: you can have these characters in VARCHAR anyway, and this way you "throw the baby out with the bath water". Not mentioning that right now also immune formats like HTML are also limited.
-
Bad performance with many xmlqueries in select and big resultset
I'm running into big performance problems with the following query (edited the query a bit to remove sensitive information):
SELECT id "id",created "created",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element2/name' passing xml returning content) as varchar2(182))"element2Name",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element3/name' passing xml returning content) as varchar2(182))"element3Name",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/ror/gcor' passing xml returning content) as varchar2(5))"gcor",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:cStatus' passing xml returning content) as integer)"cStatus",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:lrrm' passing xml returning content) as integer)"lrrm",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:sent' passing xml returning content) as integer)"sent",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:success' passing xml returning content) as integer)"success",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:processStep' passing xml returning content) as integer)"processStep",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/aseod' passing xml returning content) as number(1))"aseod",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/submission/deferred' passing xml returning content) as number(1))"deferred",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/eventReportReceived' passing xml returning content) as number(1))"eventReports",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:isOpen' passing xml returning content) as number(1))"isOpen",
xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:hasNotes' passing xml returning content) as number(1))"hasNotes"
FROM tablename,xmltable(xmlnamespaces(default 'http://www.example.com/myproject/schema/namespace2','http://www.example.com/myproject/schema/common' as "c"),'/element1' passing xml columns
created timestamp path 'c:element1Header/c:creationTime/text()',
organization_id integer path 'c:element1Header/c:organization/c:organizationId/text()',
is_sender number(1) path 'c:element1Header/c:isSender/text()')
WHERE organization_id = 5 AND is_sender = 1 AND created >= sysdate-20 AND created <= sysdate+1;This query is fast as long as the results is small (<1000), but when the resultset grows bigger, the performance seems to decrease exponentially. The cause of this slowdown seems to be in the xmlqueries; commenting out the xmlqueries makes the query very fast again (in the order of a few seconds), even with a 15000+ resultset, while including the xmlqueries makes the query take many minutes.
Workaround I tried: using a rownum < 1000 works fairly well, but only if I don't use order by (which is required). order by forces the resultset to be full built regardless of the rownum limit. (this was done with a subquery orderby and a rownum on the superquery)
Other workaround i tried: Having the subquery only return the xml column, and doing the xmlqueries in the superquery. I couldn't get this to work, something about no longer having a key-preserved table.
Background info about the database: Oracle 11.2.0.3.0, binary xmltype column, with a xmlindex unstructured component on all paths in this query, and a structured component with secondary indexes on the paths used in the WHERE (created, organization_id and is_sender). Database has about 140k records total.
My question is, if anyone knows if this xmlquery bottleneck can be remedied somehow?
Addition: graph i made indicating the performance at different resultset sizes. Horizontal axis is size of resultset, vertical axis is time spent in seconds: http://i.imgur.com/F2tyg.pngJust count(*), nothing else in the select:
COUNT(*)
15432
Plan hash value: 1584286506
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 39 | 31 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 39 | | |
|* 2 | FILTER | | | | | |
| 3 | NESTED LOOPS | | 15 | 585 | 31 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 15 | 405 | 16 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | TABLENAME_SC_SUB_IX | 15 | | 3 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY USER ROWID | TABLENAME | 1 | 12 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(SYSDATE@!-500<=SYSDATE@!-50)
5 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
"SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)Original query with ORDER BY on 2 structured component columns, 1 descending and 1 ascending (NOTE: While the explain plan says the time is 00:00:01, the query takes 763 seconds to complete)
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 15 | 23880 | 32 (4)| 00:00:01 |
| 1 | SORT GROUP BY | | 1 | 41 | | |
|* 2 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 4 | SORT GROUP BY | | 1 | 41 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 16 | 656 | 5 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 16 | | 3 (0)| 00:00:01 |
| 7 | SORT GROUP BY | | 1 | 41 | | |
|* 8 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 15 | 615 | 4 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 15 | | 3 (0)| 00:00:01 |
| 10 | SORT GROUP BY | | 1 | 41 | | |
|* 11 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 12 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 13 | SORT GROUP BY | | 1 | 41 | | |
|* 14 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 16 | SORT GROUP BY | | 1 | 41 | | |
|* 17 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 19 | SORT GROUP BY | | 1 | 41 | | |
|* 20 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 22 | SORT GROUP BY | | 1 | 41 | | |
|* 23 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 25 | SORT GROUP BY | | 1 | 41 | | |
|* 26 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 1 | 41 | 4 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 1 | | 3 (0)| 00:00:01 |
| 28 | SORT GROUP BY | | 1 | 41 | | |
|* 29 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 8 | 328 | 4 (0)| 00:00:01 |
|* 30 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 8 | | 3 (0)| 00:00:01 |
| 31 | SORT GROUP BY | | 1 | 41 | | |
|* 32 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 1 | 41 | 4 (0)| 00:00:01 |
|* 33 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 1 | | 3 (0)| 00:00:01 |
| 34 | SORT GROUP BY | | 1 | 41 | | |
|* 35 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 36 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 37 | SORT ORDER BY | | 15 | 23880 | 32 (4)| 00:00:01 |
|* 38 | FILTER | | | | | |
| 39 | NESTED LOOPS | | 15 | 23880 | 31 (0)| 00:00:01 |
| 40 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 15 | 1350 | 16 (0)| 00:00:01 |
|* 41 | INDEX RANGE SCAN | TABLENAME_SC_SUB_IX | 15 | | 3 (0)| 00:00:01 |
| 42 | TABLE ACCESS BY USER ROWID | TABLENAME | 1 | 1502 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
38 - filter(SYSDATE@!-500<=SYSDATE@!-50)
41 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
"SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
Note
- Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)The same query with ORDER BY only on CREATED DESC (takes 15 seconds to complete):
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 15 | 23880 | 31 (0)| 00:00:01 |
| 1 | SORT GROUP BY | | 1 | 41 | | |
|* 2 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 4 | SORT GROUP BY | | 1 | 41 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 16 | 656 | 5 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 16 | | 3 (0)| 00:00:01 |
| 7 | SORT GROUP BY | | 1 | 41 | | |
|* 8 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 15 | 615 | 4 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 15 | | 3 (0)| 00:00:01 |
| 10 | SORT GROUP BY | | 1 | 41 | | |
|* 11 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 12 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 13 | SORT GROUP BY | | 1 | 41 | | |
|* 14 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 16 | SORT GROUP BY | | 1 | 41 | | |
|* 17 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 19 | SORT GROUP BY | | 1 | 41 | | |
|* 20 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 22 | SORT GROUP BY | | 1 | 41 | | |
|* 23 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
| 25 | SORT GROUP BY | | 1 | 41 | | |
|* 26 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 1 | 41 | 4 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 1 | | 3 (0)| 00:00:01 |
| 28 | SORT GROUP BY | | 1 | 41 | | |
|* 29 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 8 | 328 | 4 (0)| 00:00:01 |
|* 30 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 8 | | 3 (0)| 00:00:01 |
| 31 | SORT GROUP BY | | 1 | 41 | | |
|* 32 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 1 | 41 | 4 (0)| 00:00:01 |
|* 33 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 1 | | 3 (0)| 00:00:01 |
| 34 | SORT GROUP BY | | 1 | 41 | | |
|* 35 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 17 | 697 | 5 (0)| 00:00:01 |
|* 36 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
|* 37 | FILTER | | | | | |
| 38 | NESTED LOOPS | | 15 | 23880 | 31 (0)| 00:00:01 |
| 39 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 15 | 1350 | 16 (0)| 00:00:01 |
|* 40 | INDEX RANGE SCAN DESCENDING| TABLENAME_SC_SUB_IX | 15 | | 3 (0)| 00:00:01 |
| 41 | TABLE ACCESS BY USER ROWID | TABLENAME | 1 | 1502 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
37 - filter(SYSDATE@!-500<=SYSDATE@!-50)
40 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
"SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
Note
- Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)Removing all XmlQueries from the SELECT and adding 1 of them to the XmlTable in the FROM (full table scan, takes 25 seconds to complete):
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1522 | 2232K| 15515 (3)| 00:03:07 |
| 1 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 21 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 32 | 2 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 23 | 2 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 27 | 2 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 9 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 18 | 2 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID | TABLENAME_SC | 1 | 13 | 2 (0)| 00:00:01 |
|* 12 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
|* 13 | TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE | 1 | 37 | 4 (0)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | SYS63339_TABL_XML_I_PIKEY_IX | 17 | | 3 (0)| 00:00:01 |
|* 15 | FILTER | | | | | |
|* 16 | TABLE ACCESS FULL | TABLENAME | 1522 | 2232K| 9423 (4)| 00:01:54 |
| 17 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 1 | 13 | 2 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 19 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 1 | 13 | 2 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 1 | 21 | 2 (0)| 00:00:01 |
|* 22 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
| 23 | TABLE ACCESS BY INDEX ROWID| TABLENAME_SC | 1 | 21 | 2 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | SYS63339_63348_RID_IDX | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("SYS_SXI_7"."RID"=:B1)
4 - access("SYS_SXI_6"."RID"=:B1)
6 - access("SYS_SXI_5"."RID"=:B1)
8 - access("SYS_SXI_4"."RID"=:B1)
10 - access("SYS_SXI_3"."RID"=:B1)
12 - access("SYS_SXI_2"."RID"=:B1)
13 - filter(SYS_XMLI_LOC_ISTEXT("SYS_P0"."LOCATOR","SYS_P0"."PATHID")=1)
14 - access("SYS_P0"."RID"=:B1 AND "SYS_P0"."PATHID"=HEXTORAW('509D') )
15 - filter(CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
SYS_XQ_PKSQL2XML("SYS_SXI_11"."ORGANIZATION_ID",2,4,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_11" WHERE
"SYS_SXI_11"."RID"=:B1),0,0,54525952,0),50,1,2)) AS integer )=6 AND
CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT SYS_XQ_PKSQL2XML("SYS_SXI_10"."IS_SENDER",2,4,2)
FROM "USERN"."TABLENAME_SC" "SYS_SXI_10" WHERE "SYS_SXI_10"."RID"=:B2),0,0,54525952,0),50,1,2)) AS
number(1) )=1 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
SYS_XQ_PKSQL2XML("SYS_SXI_9"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_9" WHERE
"SYS_SXI_9"."RID"=:B3),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
)>=SYSDATE@!-300 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
SYS_XQ_PKSQL2XML("SYS_SXI_8"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_8" WHERE
"SYS_SXI_8"."RID"=:B4),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
)<=SYSDATE@!-200)
16 - filter(EXISTSNODE(SYS_MAKEXML(0,"SYS_ALIAS_11"."SYS_NC00003$"),'/oraxq_defpfx:element1','
xmlns:oraxq_defpfx="http://www.example.com/myproject/schema/namespace2"')=1)
18 - access("SYS_SXI_11"."RID"=:B1)
20 - access("SYS_SXI_10"."RID"=:B1)
22 - access("SYS_SXI_9"."RID"=:B1)
24 - access("SYS_SXI_8"."RID"=:B1)Index creation script:
CREATE INDEX tabl_xml_ix
ON tablename(xml)
INDEXTYPE IS XDB.XMLIndex
PARAMETERS('
PATHS (INCLUDE (/element1/common:header/common:kind
/element1/common:element1Header/common:referenceNumber
/element1/common:element1Header/common:reference
/element1/common:element1Header/common:organization/common:organizationId
/element1/common:element1Header/common:status/common:cStatus
/element1/common:element1Header/common:status/common:isOpen
/element1/common:element1Header/common:status/common:processStep
/element1/common:element1Header/common:status/common:lrrm
/element1/common:element1Header/common:status/common:sent
/element1/common:element1Header/common:status/common:success
/element1/common:element1Header/common:creationTime)
NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
xmlns:common="http://www.example.com/myproject/schema/common"))');
ALTER INDEX tabl_xml_ix
PARAMETERS ('PATHS (INCLUDE ADD (/element1/e/referenceCode
/element1/e/header/sNumber
/element1/element2/name
/element1/element3/name
/element1/element4/id
/element1/submission/deferred
/element1/common:element1Header/common:organization/common:pNumber
/element1/e/iNumber
/element1/header/status/aseod
/element1/common:element1Header/common:isSender
/element1/ror/gcor
/element1/header/status/eventReportReceived
/element1/pod/eNumber)
NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
xmlns:common="http://www.example.com/myproject/schema/common"))');
BEGIN
DBMS_XMLINDEX.registerParameter(
'tablename_add_sc','ADD_GROUP GROUP tablename_group
XMLTABLE tablename_sc
XMLNAMESPACES(
DEFAULT ''http://www.example.com/myproject/schema/namespace2'',
''http://www.example.com/myproject/schema/common'' AS "common"
''/element1''
COLUMNS
is_sender NUMBER(1) path ''common:element1Header/common:isSender/text()'',
creation_time TIMESTAMP PATH ''common:element1Header/common:creationTime/text()'',
rn VARCHAR2(22 CHAR) PATH ''common:element1Header/common:referenceNumber/text()'',
rc VARCHAR2(21) PATH ''e/referenceCode/text()'',
reference VARCHAR2(35 CHAR) PATH ''common:element1Header/common:reference/text()'',
i_nr VARCHAR2(35 CHAR) PATH ''e/iNumber/text()'',
p_nr VARCHAR2(32) PATH ''common:element1Header/common:organization/common:pNumber/text()'',
pod_e_nr VARCHAR2(13) PATH ''pod/eNumber/text()'',
d_id VARCHAR2(16) PATH ''element4/id/text()'',
organization_id INTEGER PATH ''common:element1Header/common:organization/common:organizationId/text()'',
sequence_number INTEGER PATH ''e/eHeader/sequenceNumber/text()''
END;
ALTER INDEX tabl_xml_ix PARAMETERS('PARAM tablename_add_sc');
create index tablename_sc_rn_ix on tablename_sc(rn);
create index tablename_sc_time_ix on tablename_sc(creation_time);
create index tablename_sc_sub_ix on tablename_sc (organization_id, is_sender, creation_time);Edited by: Michiel Weggen on Apr 11, 2012 2:02 AM Reason: Forgot secondary indexes.
Edited by: Michiel Weggen on Apr 11, 2012 5:51 AM: changed path of d_id to element4/id in the structured component -
PIVOT with multiple columns to add and multiple levels of grouping
Hi friends,
I got a table with the columns in the form of:
CRITERIA_A,
CRITERIA_B,
CRITERIA_C,
AMOUNT_A,
AMOUNT_B,
AMOUNT_C,
AMOUNT_D
Any way to design a pivot to present the table reflecting:
Sums of Amount_A, Amount_B, Amount_C, Amount_D
For Rows reflecting grouping levels on:
Criteria_B, Criteria_C
and Columns breakup for:
Criteria_A?
An example like:
Criteria_A1
Criteria_A2
Criteria_A3
Criteria_A4
Row Labels
Sum of Amount_A
Sum of Amount_B
Sum of Amount_C
Sum of Amount_D
Sum of Amount_A
Sum of Amount_B
Sum of Amount_C
Sum of Amount_D
Sum of Amount_A
Sum of Amount_B
Sum of Amount_C
Sum of Amount_D
Sum of Amount_A
Criteria_B3
94
107
36
127
84
132
41
176
24
16
67
29
38
Criteria_C1
24
25
5
49
14
66
5
49
24
16
67
29
Criteria_C2
70
82
31
78
38
Criteria_C3
38
41
31
78
Criteria_C4
32
25
5
49
Criteria_B1
56
142
78
26
32
25
67
8
24
Criteria_C2
24
66
26
8
32
25
67
8
Criteria_C3
32
76
52
18
Criteria_C4
24
Criteria_B2
162
309
264
81
132
230
155
124
14
25
52
8
38
Criteria_C1
38
76
26
8
62
98
98
66
14
25
52
8
38
Criteria_C2
86
157
186
44
70
132
57
58
Criteria_C3
38
76
52
29
Criteria_B4
100
148
130
116
56
142
93
57
46
Criteria_C1
24
66
67
49
32
Criteria_C2
32
76
26
8
14
Criteria_C3
76
82
78
67
Criteria_C4
24
66
52
49
Grand Total
312
558
378
234
348
535
393
424
94
183
212
94
146
Thanx in advance, Best Regards, Faraz A QureshiSounds like this to me if in T-SQL query
(best guess based on what you posted)
SELECT
CRITERIA_B,
CRITERIA_C,
SUM(CASE WHEN CRITERIA_A = 'Critera_A1' THEN AMOUNT_A ELSE 0 END) AS CRITERIA_A1_AMOUNT_A,
SUM(CASE WHEN CRITERIA_A = 'Critera_A1' THEN AMOUNT_B ELSE 0 END) AS CRITERIA_A1_AMOUNT_B,
SUM(CASE WHEN CRITERIA_A = 'Critera_A1' THEN AMOUNT_C ELSE 0 END) AS CRITERIA_A1_AMOUNT_C,
SUM(CASE WHEN CRITERIA_A = 'Critera_A2' THEN AMOUNT_A ELSE 0 END) AS CRITERIA_A2_AMOUNT_A,
SUM(CASE WHEN CRITERIA_A = 'Critera_A2' THEN AMOUNT_B ELSE 0 END) AS CRITERIA_A2_AMOUNT_B,
SUM(CASE WHEN CRITERIA_A = 'Critera_A2' THEN AMOUNT_C ELSE 0 END) AS CRITERIA_A2_AMOUNT_C,
SUM(CASE WHEN CRITERIA_A = 'Critera_AN' THEN AMOUNT_A ELSE 0 END) AS CRITERIA_AN_AMOUNT_A,
SUM(CASE WHEN CRITERIA_A = 'Critera_AN' THEN AMOUNT_B ELSE 0 END) AS CRITERIA_AN_AMOUNT_B,
SUM(CASE WHEN CRITERIA_A = 'Critera_AN' THEN AMOUNT_C ELSE 0 END) AS CRITERIA_AN_AMOUNT_C,
FROM Table
GROUP BY CRITERIA_B,
CRITERIA_C
to make it dynamic see
http://beyondrelational.com/modules/2/blogs/70/posts/10791/dynamic-crosstab-with-multiple-pivot-columns.aspx
However it would be much easier to build this in SSRS reports using matrix if you can use it.
In that case just bring data as is
then add a matrix to report
Add column grouping on Criteria A and Row grouping on Criteria B and then Criteria C .
In data portion add three columns with expressions as
=SUM(Fields!Amount_A.Value)
=SUM(Fields!Amount_B.Value)
=SUM(Fields!Amount_C.Value)
then you will get exact format what you're asking for
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Show clob column in TextArea and save the format
Hi, everybody!
I have a problem and if someone is able to help me it will be great!
I have column SQL_PLAN_TEXT (CLOB) which has the sql plan of certain statement.
I would like to show the sql plan of statement A and next to it the sql plan of statement B.
I decided to use to TextArea items situated next to each other . Everything works except that the format of the text in tetxtareas is not the same as when I opened the clob column in the database.
Any ideas ?I've never worked with Clobs in Excel output, but from the sounds of it, all of your data is present in the Excel output, it's just that the column is not wide enough or the cell is not tall enough to display all of the data.
As "rick_me" wrote in this post Re: Number and cell formatting in RTF
Excel takes it's cue from the RTF template for how to size the columns.
You can also give Excel general guidlines as to the row height.
Put your data into a Table in the RTF template and experiment by altering the height and width of the table cells. -
Handling Large list with 150+ columns(40+ Searchable) and 100000 rows.
Hi All,
We are working on project architecture for project with the following issue:
1. List having 150+ columns out of which:
- 40+ columns need to have search (i.e Indexing)
- 30+ lookup columns
- 10+ date time columns
- 40+ multiline text columns
2. List having 100000+ records
- As per business we don’t have any specific folder criteria to divide list items into folders.
Business Requirements:
- filter on the list (it should show real time data so can’t use SharePoint Search)
- Export to Excel 30000+ data in <30 Sec
Our list is already normalized and we don’t see any scope to normalize it further.
Problems of breaking the list into multiple list:
1.)Low performance as join is taking very much time(due to 30,000 items)
2.)Secure transaction problem i.e. suppose we broke list into 5 child lists. Now if I need to add an item in list then it has to be implemented by adding part of item to each child list.
There may arise problem such as items inserted to 4 list successfully but failed in insertion into last list.
Thank you in advance.
Thanks, SatishHi All,
We solved this problem by normalizing list into many list.
Then creating one search list with all columns as plain text no look up this list have all the columns from all different list. Then writing event receiver to update this search list on item change.
and one timer job which will delete and recreate this search list weakly.
Let me know if you have any better solution.
-Satish
Maybe you are looking for
-
I really just want to watch Frozen and it wont download. The option to download it won't even show up anymore. I'm desperate for help
-
How can I fix consistent TCP timeout and make data flow simpler?
Hi! I'm acquiring data from a Scanivalve Digital Scanning Array through a TCP/IP connection. I'm having problems with the connection timing out regularly. It will run fine if you take data several times in a row, but if the VI sits for several minute
-
Save as PDF' splits MS-Word Sections into separate PDFs
This is more of an FYI than a question, Original topic: http://discussions.info.apple.com/message.jspa?messageID=8068226 it has already been archived and I can't reply to it. Problem description: when printing a single work document to PDF two PDF fi
-
Function to bounce single tracks of a project automatically?
Hi guys Is there any function i can use on logic 9, which bounces all the single tracks of a project automatically? I have to bounce everything in Audio, cause I am about to send the stems to someone.. The project has 88 tracks so its quite a job to
-
Python-matplotlib and dependencies
To day I tried to install python-matplotlib, but it dependet on, and tried to install wxpython and tk, which in turn depends on old usless gtk-1 and glib-1. All together 17 MB. Why is that, you can easily build this package without all those dependen