XPath query against XMLType
Hello,
I am trying to reproduce the following XPath query using XDB functionality against a XMLType column:
//AtomicPart[@MyID='190' or @MyID='495' or @MyID='1662']
If I do the following I do get all AtomicParts:
select X.xml.extract('//AtomicPart') FROM TEST X
But I havent figured out how to do the or operation. Is it possible or does it require views?
Thank you,
Robert
Robert
Need to see the instance document in order to answer this..
Similar Messages
-
Why Is Query Against XMLTYPE Table ACME_CUST Doing A Full Table Scan?
On our Oracle Database 11g Enterprise Edition Release 11.2.0.1.0, we have a query against against a 25,214 record XMLTYPE ACME_CUST table.
SELECT rownum AS seq,
EID AS eid,
SUBSTR(CUST_ID, 1, INSTR(CUST_ID, '|')-1) AS tgt_acme_customer_id,
SUBSTR(CUST_ID, INSTR(CUST_ID, '|') +1) AS src_acme_customer_id_list
FROM
(SELECT ac.eid EID,
listagg(ac.acme_cust_id, '|') WITHIN GROUP (
ORDER BY ac.acme_cust_id, ac.acme_cust_id) CUST_ID
FROM ACME_CUST ac
GROUP BY ac.eid
HAVING COUNT(ac.acme_cust_id)>1)Explain plan shows:
Select Statement
Count
VIEW
FILTER
Filter Predicates
COUNT(*) > 1
SORT GROUP BY
TABLE ACCESS ACME_CUST FULL
The ACME_CUST Table has a virtual column defined on acme_cust_id along with a corresponding index. This filed is also defined as a primary key.
Here is the table definitiion and associated statements:
CREATE
TABLE "N98991"."ACME_CUST" OF XMLTYPE
CONSTRAINT "ACME_CUST_ID_PK" PRIMARY KEY ("ACME_CUST_ID") USING INDEX
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536
NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
DEFAULT) TABLESPACE "ACME_DEV" ENABLE
XMLTYPE STORE AS SECUREFILE BINARY XML
TABLESPACE "ACME_DEV" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT)
ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
"EID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@eid'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(15))),
*bold* "ACME_CUST_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@id' *bold*
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
"CRET_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@create_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE)))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CST_CRET_DT_IDX" ON "N98991"."ACME_CUST"
"CRET_DT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CST_EID_IDX" ON "N98991"."ACME_CUST"
"EID"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DEV" ;
*bold*CREATE UNIQUE INDEX "N98991"."ACME_CUST_ID_PK" ON "N98991"."ACME_CUST"
"ACME_CUST_ID"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE *bold*
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CUST_XMLINDEX_IX" ON "N98991"."ACME_CUST"
OBJECT_VALUE
INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
'XMLTABLE ACME_CUST_IDX_TAB XMLNamespaces (''http://www.cigna.com/acme/domains/commoncontact/2011/11'' as "cm", default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),
''/customerProfile''
columns
DOB date PATH ''personInformation/cm:birthDate'',
FIRSTNAME varchar2(40) PATH ''name/cm:givenName'',
LASTNAME varchar2(40) PATH ''name/cm:surName'',
SSN varchar2(30) PATH ''identifiers/ssn'',
MEMBERINFOS XMLType path ''memberInfos/memberInfo'' VIRTUAL
XMLTable acme_cust_lev2_idx_tab XMLNAMESPACES(default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),
''/memberInfo'' passing MEMBERINFOS
columns
ami varchar2(40) PATH ''ami'',
subscId varchar2(50) PATH ''clientRelationship/subscriberInformation/subscriberId'',
employeeId varchar2(50) PATH ''systemKeys/employeeId'',
clientId varchar2(50) PATH ''clientRelationship/clientId''
CREATE UNIQUE INDEX "N98991"."SYS_C00384339" ON "N98991"."ACME_CUST"
"SYS_NC_OID$"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DEV" ;
CREATE UNIQUE INDEX "N98991"."SYS_IL0000649948C00003$$" ON "N98991"."ACME_CUST"
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "ACME_DEV" PARALLEL (DEGREE 0 INSTANCES 0) ;Why isn't the unique index ACME_CUST_ID_PK on the virtual column ACME_CUST_ID being used in the explain plan?
Any input would be much appreciated, as really stumped here.
Regards,
RickHi Richard,
The 10053 event appears overkill for this situation. What's the big deal?
Set the event, run the query, unset the event, check the trace file, that's all.
It's not overkill if it helps you understanding what happens and why an index is of no use in this situation.
Tried the /*+ INDEX_FFS(ACME_CUST_ID_PK) */ hint in the 'nested' query.Not sure what nested query you're referring to, so if I misunderstood what you mean, just ignore the following comment.
From what you posted earlier, it looks like you're talking about this part :
listagg(ac.acme_cust_id,'|') WITHIN GROUP (
ORDER BY ac.acme_cust_id,ac.acme_cust_id) CUST_IDThat's not a nested query, it's a projection. All the main work (retrieving rows) has already been done when it comes to this part.
May just have to accept the query performance as it is...Maybe you can try something else.
See the document : Oracle XML DB : Best Practices, page 15 ex. 8 :
When there are multiple scalar values that need to be grouped or ordered, it is better to write it
with XMLTable construct that projects out all columns to be ordered or grouped as shown
below.Here's an example close to your actual requirement :
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> create table xtab_cols of xmltype
2 xmltype store as securefile binary xml;
Table created.
SQL> insert /*+ append */ into xtab_cols
2 select xmlelement("ROW",
3 xmlforest(
4 TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
5 DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
6 DEFAULT_LENGTH, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
7 DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
8 CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
9 GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
10 V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
11 )
12 )
13 from dba_tab_cols
14 where owner = 'SYS'
15 ;
57079 rows created.
SQL> commit;
Commit complete.
SQL> set long 1000
SQL> set pages 100
SQL> select xmlserialize(document object_value) from xtab_cols where rownum = 1;
XMLSERIALIZE(DOCUMENTOBJECT_VALUE)
<ROW>
<TABLE_NAME>ACCESS$</TABLE_NAME>
<COLUMN_NAME>D_OBJ#</COLUMN_NAME>
<DATA_TYPE>NUMBER</DATA_TYPE>
<DATA_LENGTH>22</DATA_LENGTH>
<NULLABLE>N</NULLABLE>
<COLUMN_ID>1</COLUMN_ID>
<NUM_DISTINCT>7454</NUM_DISTINCT>
<LOW_VALUE>C2083A</LOW_VALUE>
<HIGH_VALUE>C3031D18</HIGH_VALUE>
<DENSITY>,000134156157767642</DENSITY>
<NUM_NULLS>0</NUM_NULLS>
<NUM_BUCKETS>1</NUM_BUCKETS>
<LAST_ANALYZED>2012-01-28</LAST_ANALYZED>
<SAMPLE_SIZE>34794</SAMPLE_SIZE>
<GLOBAL_STATS>YES</GLOBAL_STATS>
<USER_STATS>NO</USER_STATS>
<AVG_COL_LEN>5</AVG_COL_LEN>
<CHAR_LENGTH>0</CHAR_LENGTH>
<V80_FMT_IMAGE>NO</V80_FMT_IMAGE>
<DATA_UPGRADED>YES</DATA_UPGRADED>
<HISTOGRAM>NONE</HISTOGRAM>
</ROW>
SQL> exec dbms_stats.gather_table_stats(user, 'XTAB_COLS');
PL/SQL procedure successfully completed.
SQL> set autotrace traceonly
SQL> set timing on
SQL> set lines 120
SQL> select x.table_name
2 , listagg(x.column_name, ',') within group (order by column_id)
3 from xtab_cols t
4 , xmltable('/ROW' passing t.object_value
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID'
8 ) x
9 group by x.table_name
10 ;
4714 rows selected.
Elapsed: 00:00:08.25
Execution Plan
Plan hash value: 602782846
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 466M| 101G| 1580K (3)| 05:16:04 |
| 1 | SORT GROUP BY | | 466M| 101G| 1580K (3)| 05:16:04 |
| 2 | NESTED LOOPS | | 466M| 101G| 1552K (1)| 05:10:32 |
| 3 | TABLE ACCESS FULL| XTAB_COLS | 57079 | 12M| 408 (1)| 00:00:05 |
| 4 | XPATH EVALUATION | | | | | |
Statistics
9 recursive calls
1 db block gets
1713 consistent gets
0 physical reads
96 redo size
773516 bytes sent via SQL*Net to client
3873 bytes received via SQL*Net from client
316 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
4714 rows processedAnd of course, even better after adding a structured XML index (4714 rows fetched in 1s) :
SQL> CREATE INDEX xtab_cols_sxi ON xtab_cols (OBJECT_VALUE) INDEXTYPE IS XDB.XMLIndex
2 PARAMETERS (
3 q'#XMLTable my_xtab
4 '/ROW'
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID' #');
Index created.
Elapsed: 00:00:13.42
SQL> select x.table_name
2 , listagg(x.column_name, ',') within group (order by column_id)
3 from xtab_cols t
4 , xmltable('/ROW' passing t.object_value
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID'
8 ) x
9 group by x.table_name
10 ;
4714 rows selected.
Elapsed: 00:00:01.00
Execution Plan
Plan hash value: 3303494605
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 57520 | 3201K| 174 (3)| 00:00:03 |
| 1 | SORT GROUP BY | | 57520 | 3201K| 174 (3)| 00:00:03 |
| 2 | TABLE ACCESS FULL| MY_XTAB | 57520 | 3201K| 171 (1)| 00:00:03 |
Note
- dynamic sampling used for this statement (level=2)
Statistics
297 recursive calls
1 db block gets
989 consistent gets
0 physical reads
176 redo size
773516 bytes sent via SQL*Net to client
3873 bytes received via SQL*Net from client
316 SQL*Net roundtrips to/from client
21 sorts (memory)
0 sorts (disk)
4714 rows processed -
I'm hung up on something that I suspect is very easy, but I have little experience working with XML in the database and think I've just stared at it too long.
I have an XML document (fragment below) stored as an XMLType in a 10g R2 database table and I want to return the following result set from a query against the document:
PAGE_ID PAGE_SUBMISSION_FIELD
21 F39EF21
21 F85FG3E
21 F73EF58
21 FA4939F
22 FDE77A4
22 FF3AD33
Here is a fragment of the XML document:
<root-interface>
<page-group>
<display-page validation-state="new">
<id>21</id>
<page-submission-fields>
<page-submission-field>F39EF21</page-submission-field>
<page-submission-field>F85FG3E</page-submission-field>
<page-submission-field>F73EF58</page-submission-field>
<page-submission-field>FA4939F</page-submission-field>
</page-submission-fields>
</display-page>
<display-page validation-state="new">
<id>22</id>
<page-submission-fields>
<page-submission-field>FDE77A4</page-submission-field>
<page-submission-field>FF3AD33</page-submission-field>
</page-submission-fields>
</display-page>
</page-group>
</root-interface>
Here is the table in which it is stored:
desc cms_session_interfaces
Name Null? Type
SESSION_ID NOT NULL NUMBER
INTERFACE_ID NOT NULL NUMBER
CREATED NOT NULL DATE
LAST_ACCESSED DATE
INTERFACE_XML SYS.XMLTYPE
Here is a close as I've come with a query:
select extract(value(display_pages), '//id/text()').getStringVal() page_id,
extract(value(display_pages), '//page-submission-fields/page-submission-field') page_submission_field
from cms_session_interfaces csi,
table(xmlsequence(extract(csi.interface_xml, '//root-interface/page-group/display-page'))) display_pages
where csi.session_id = 41
and csi.interface_id = 596
(the specified session_id and interface_id are just for testing purposes)
This returns two rows consisting of the PAGE_ID and an object of XMLType containing the page-submission fields. Almost there, but not quite; any suggestions would be appreciated.As Marco said, xmltable is very handy:
SQL> with cms_session_interfaces as (
2 select XMLType('
3 <root-interface>
4 <page-group>
5 <display-page validation-state="new">
6 <id>21</id>
7 <page-submission-fields>
8 <page-submission-field>F39EF21</page-submission-field>
9 <page-submission-field>F85FG3E</page-submission-field>
10 <page-submission-field>F73EF58</page-submission-field>
11 <page-submission-field>FA4939F</page-submission-field>
12 </page-submission-fields>
13 </display-page>
14 <display-page validation-state="new">
15 <id>22</id>
16 <page-submission-fields>
17 <page-submission-field>FDE77A4</page-submission-field>
18 <page-submission-field>FF3AD33</page-submission-field>
19 </page-submission-fields>
20 </display-page>
21 </page-group>
22 </root-interface>') interface_xml
23 from dual)
24 select page.id,fields.field
25 from cms_session_interfaces csi,
26 xmltable('//root-interface/page-group/display-page'
27 passing interface_xml
28 columns
29 id varchar2(10) path 'id',
30 page_fields xmltype path 'page-submission-fields') page,
31 xmltable('/page-submission-fields/page-submission-field'
32 passing page_fields
33 columns
34 field varchar2(25) path '.') fields
35 /
ID FIELD
21 F39EF21
21 F85FG3E
21 F73EF58
21 FA4939F
22 FDE77A4
22 FF3AD33
6 rows selected.Best regards
Maxim -
(urgent) How to make sumarize query against XMLType?
Hello,
i have xml document like this
<List>
<Item>
<A>10</A>
<B>554</B>
<C>25.5.2005</C>
</Item>
<Item>
<A>20</A>
<B>49</B>
<C>26.5.2005</C>
</Item>
<Item>
<A>30</A>
<B>184</B>
<C>27.5.2005</C>
</Item>
</List>
in xmltype variable (not table column) and i need e.g. sum (or count or something like that) values in xpath /List/Item/B in one document.
Is there some quick and elegant way to do this?
Thanks for quick help.Maybe the below will help.
Did you look at building a view over the xmltype extracting the values into a relational type view, then using the view to sum up the values.
Jonthan Gennick has an article on the Oracle OTN website with the below code.
CREATE VIEW cd_master (Title, Artist, Website, Description) AS
SELECT extractValue(value(x),'/CD/Title'),
extractValue(value(x),'/CD/Artist'),
extractValue(value(x),'/CD/Website'),
extractValue(value(x),'/CD/Description')
FROM CD331_TAB x;
CREATE INDEX by_artist ON CD331_TAB x (
extractValue(value(x),'/CD/Artist'));
ANALYZE TABLE cd331_tab COMPUTE STATISTICS FOR TABLE;
ANALYZE INDEX by_artist COMPUTE STATISTICS; -
Does anyone know if there is an easy way to run an XPath query against a CLOB column? I know it's simple if the column is XMLType, but what if it's a CLOB?
Does CLOB store XML? If so, simply use XMLTYPE(clob_column).
SY. -
Xpath query depenedent on new line chars
Hi,
I am trying to run an XPath query against a String which contains the XML. I am using Apache Commons IOUtils
to convert String to InputStream
If the String contains new line chars in it then I get unexpected results. However if XML is one looong string then there
is no problem.
What can I do to avoid this problem.
public static void main(String[] args)
throws XPathFactoryConfigurationException,
XPathExpressionException, ParserConfigurationException,
SAXException, IOException {
// System.out.println(XML);
XPathFactory xpathFactory = XPathFactory
.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI);
XPath xpath = xpathFactory.newXPath();
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
// Use XML_STRING as the xml to reproduce the error
Document document = documentBuilder.parse(IOUtils.toInputStream(XML_STRING));
NodeList xpathResult = (NodeList) xpath.evaluate("/Envelope/Body",
document, XPathConstants.NODESET);
Node node = xpathResult.item(0).getFirstChild();
String requestName = node.getNodeName();
requestName = requestName.split(":",-1)[1];
System.out.println(requestName);
String sessionIdXqry = "/Envelope/Body/" + requestName + "/sessionId";
System.out.println(sessionIdXqry);
String sessionId = (String)xpath.evaluate(sessionIdXqry, document, XPathConstants.STRING);
System.out.println("SessionID = " + sessionId);
}You can't call methods in EL like that - write a custom tag that transforms the data in the way you want (replacing newlines with "<br>"). Then:
<something:yourNewTag text="${row.description}" /> -
XPath query to test for the existence of a tag
I have the following piece of XML and I need to write a query against it that will check for the existence of the <content> tag in XML body... In other words, I want to get the row if the <content> tag is absent from the Asset portion of the metadata but only for Asset_Class = "encrypted"
ADI>
−
<Metadata>
<AMS Asset_Class="package" Asset_ID="TTVV4136100000000001" Asset_Name="Package_4136" Creation_Date="2004-07-12" Description="Test package C1" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="0"/>
<App_Data App="MOD" Name="Provider_Content_Tier" Value="HBO1"/>
<App_Data App="MOD" Name="Metadata_Spec_Version" Value="CableLabsVOD1.1"/>
</Metadata>
−
<Asset>
−
<Metadata>
<AMS Asset_Class="title" Asset_ID="TTVV4136100000000002" Asset_Name="Package_4136_Title" Creation_Date="2004-07-12" Description="Test package C1 title" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="0"/>
<App_Data App="MOD" Name="Distributor_Royalty_Percent" Value="12.11"/>
<App_Data App="MOD" Name="Contract_Name" Value="Contract Name"/>
<App_Data App="MOD" Name="Box_Office" Value="184000000"/>
<App_Data App="MOD" Name="MSORating" Value="R"/>
<App_Data App="MOD" Name="Distributor_Royalty_Flat_Rate" Value="15.549"/>
<App_Data App="MOD" Name="Studio_Name" Value="N2Broadband, INC"/>
<App_Data App="MOD" Name="Season_Premiere" Value="N"/>
<App_Data App="MOD" Name="Country_of_Origin" Value="USA"/>
<App_Data App="MOD" Name="Actors_Display" Value="Harrison Ford, Tommy Lee Jones, Sela Ward"/>
<App_Data App="MOD" Name="Propagation_Priority" Value="1"/>
<App_Data App="MOD" Name="Title_Sort_Name" Value="Pkg C1"/>
<App_Data App="MOD" Name="Director" Value="Villaveces,Eduardo"/>
<App_Data App="MOD" Name="Genre" Value="Test"/>
<App_Data App="MOD" Name="Director" Value="Robertson,Mark"/>
<App_Data App="MOD" Name="Summary_Short" Value="Test Package C1 Summary_Short"/>
<App_Data App="MOD" Name="Closed_Captioning" Value="Y"/>
<App_Data App="MOD" Name="Studio_Royalty_Minimum" Value="13.000"/>
<App_Data App="MOD" Name="Producers" Value="phillips,chris"/>
<App_Data App="MOD" Name="Studio" Value="Warner Bros."/>
<App_Data App="MOD" Name="Rating" Value="G"/>
<App_Data App="MOD" Name="Rating" Value="TV-G"/>
<App_Data App="MOD" Name="Category" Value="Encryption Test"/>
<App_Data App="MOD" Name="Provider_QA_Contact" Value="[email protected]"/>
<App_Data App="MOD" Name="Display_As_Last_Chance" Value="40"/>
<App_Data App="MOD" Name="Writer_Display" Value="test of writers disp"/>
<App_Data App="MOD" Name="Home_Video_Window" Value="45"/>
<App_Data App="MOD" Name="Billing_ID" Value="00270"/>
<App_Data App="MOD" Name="Episode_ID" Value="E ID"/>
<App_Data App="MOD" Name="Title_Brief" Value="test content"/>
<App_Data App="MOD" Name="Display_Run_Time" Value="00:03"/>
<App_Data App="MOD" Name="Maximum_Viewing_Length" Value="00:01:00"/>
<App_Data App="MOD" Name="Distributor_Name" Value="fox movies"/>
<App_Data App="MOD" Name="Studio_Royalty_Percent" Value="12.00"/>
<App_Data App="MOD" Name="Audience" Value="Adult"/>
<App_Data App="MOD" Name="Distributor_Royalty_Minimum" Value="14.552"/>
<App_Data App="MOD" Name="Display_As_New" Value="10"/>
<App_Data App="MOD" Name="Episode_Name" Value="E name"/>
<App_Data App="MOD" Name="Preview_Period" Value="60"/>
<App_Data App="MOD" Name="Title" Value="Test Package C1"/>
<App_Data App="MOD" Name="Summary_Long" Value="Test Package C1 Summary_Long"/>
<App_Data App="MOD" Name="Actors" Value="davis,bill"/>
<App_Data App="MOD" Name="Summary_Medium" Value="Test Package C1 Summary_Medium"/>
<App_Data App="MOD" Name="Licensing_Window_Start" Value="2009-10-01"/>
<App_Data App="MOD" Name="Type" Value="title"/>
<App_Data App="MOD" Name="Suggested_Price" Value="3.95"/>
<App_Data App="MOD" Name="Run_Time" Value="00:01:02"/>
<App_Data App="MOD" Name="Chapter" Value="00:01:00:00,test1"/>
<App_Data App="MOD" Name="Licensing_Window_End" Value="2011-11-01"/>
<App_Data App="MOD" Name="Subscriber_View_Limit" Value="2003-03-10,2003-03-12,12"/>
<App_Data App="MOD" Name="Season_Finale" Value="Y"/>
<App_Data App="MOD" Name="Year" Value="1993"/>
<App_Data App="MOD" Name="Studio_Royalty_Flat_Rate" Value="14.000"/>
</Metadata>
−
<Asset>
−
<Metadata>
<AMS Asset_Class="movie" Asset_ID="TTVV4136100000000003" Asset_Name="Package_4136_Movie" Creation_Date="2004-07-12" Description="Test Package movie" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="0"/>
<App_Data App="MOD" Name="Type" Value="movie"/>
<App_Data App="MOD" Name="Encryption" Value="Y"/>
<App_Data App="MOD" Name="Audio_Type" Value="Dolby Digital"/>
<App_Data App="MOD" Name="Screen_Format" Value="Standard"/>
<App_Data App="MOD" Name="Copy_Protection" Value="Y"/>
<App_Data App="MOD" Name="Content_FileSize" Value="6902796"/>
<App_Data App="MOD" Name="Content_CheckSum" Value="81647e1a3d38c4e64af3bbcf15711b40"/>
</Metadata>
<Content Value="movie4136.mpg"/>
</Asset>
−
<Asset>
−
<Metadata>
<AMS Asset_Class="poster" Asset_ID="TTVV4136100000000005" Asset_Name="Package_4136_Poster" Creation_Date="2004-07-12" Description="Test Package poster desc" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="0"/>
<App_Data App="MOD" Name="Type" Value="poster"/>
<App_Data App="MOD" Name="Image_Aspect_Ratio" Value="240x480"/>
<App_Data App="MOD" Name="Content_CheckSum" Value="999dcd45d6374feb380c0f49029911b5"/>
<App_Data App="MOD" Name="Content_FileSize" Value="30"/>
</Metadata>
<Content Value="poster4136.bmp"/>
</Asset>
−
<Asset>
−
<Metadata>
<AMS Asset_Class="preview" Asset_ID="TTVV4136100000000004" Asset_Name="Package_4136_Preview" Creation_Date="2004-07-12" Description="Test Package Preview" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="0"/>
<App_Data App="MOD" Name="Type" Value="preview"/>
<App_Data App="MOD" Name="Screen_Format" Value="Standard"/>
<App_Data App="MOD" Name="Audience" Value="General"/>
<App_Data App="MOD" Name="MSORating" Value="All-Ages"/>
<App_Data App="MOD" Name="Audio_Type" Value="Dolby Digital"/>
<App_Data App="MOD" Name="Languages" Value="en"/>
<App_Data App="MOD" Name="Dubbed_Languages" Value="is"/>
<App_Data App="MOD" Name="Subtitle_Languages" Value="is"/>
<App_Data App="MOD" Name="Rating" Value="G"/>
<App_Data App="MOD" Name="Rating" Value="TV-14 S"/>
<App_Data App="MOD" Name="Run_Time" Value="00:03:54"/>
<App_Data App="MOD" Name="Content_FileSize" Value="6902796"/>
<App_Data App="MOD" Name="Content_CheckSum" Value="81647e1a3d38c4e64af3bbcf15711b40"/>
</Metadata>
<Content Value="preview4136.mpg"/>
</Asset>
−
<Asset>
−
<Metadata>
<AMS Asset_Class="encrypted" Asset_ID="TTVE0000000000202939" Asset_Name="TTVV4136100000000003.n2bb.com" Creation_Date="2010-06-28" Description="Encrypted asset for movie4136.mpg" Product="MOD" Provider="N2BB" Provider_ID="n2bb.com" Verb="" Version_Major="1" Version_Minor="1"/>
<App_Data App="MOD" Name="Content_CheckSum" Value="81647e1a3d38c4e64af3bbcf15711b40"/>
<App_Data App="MOD" Name="Bit_Rate" Value="3594"/>
<App_Data App="MOD" Name="Encryption_Key_Block" Value="<?xml version="1.0" encoding="UTF-8"?><ERPayload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost/namespaces/ERPayload.xsd"> <EncryptionRecord> <ERVer1.0> <TitleIdCode>TTVV4136100000000003</TitleIdCode> <ContentTitle>TTVV4136100000000003</ContentTitle> <EncryptionTime>2010-06-23T18:18:58Z</EncryptionTime> <OLESId>268</OLESId> <Label>12138</Label> <EncryptionMode>2</EncryptionMode> <EncryptedDataVersion>0</EncryptedDataVersion> <EncryptedDataBlock>rd00X2wXJ3uQVd6tNJDimuBMNod/zkXKmxdoR5skbFOd84eVhNdX4NQAE6Nt/iX/cz4IyHXYmYpOHVvLe5GtGFqnRxkoPhBHmMpKgFtDsDX63kgM9p00qI5SEyX4F+VNudY3GZQEQQU4qP61+dXkBYMsnGm5qV18OMnF+xThCGU=</EncryptedDataBlock> </ERVer1.0> </EncryptionRecord></ERPayload>"/>
<App_Data App="MOD" Name="Receiver_Type" Value="MOTO"/>
<App_Data App="MOD" Name="Asset_Encrypted" Value="TTVV4136100000000003"/>
<App_Data App="MOD" Name="Encryption_Type" Value="oles"/>
<App_Data App="MOD" Name="Encrypting_System_Info" Value="MOTO_OLES_1"/>
<App_Data App="MOD" Name="Content_FileSize" Value="6902796"/>
</Metadata>
<Content Value="movie4136_encr.mpg"/>
</Asset>
</Asset>
</ADI>Hi,
You may use this in the WHERE clause :
EXISTSNODE(xmltype_column, 'ADI/Asset/Asset[Metadata/AMS/@Asset_Class="encrypted"]/Content') = 0The XML has to be stored in an XMLType column, is that the case? -
I have stored a typical Purchase Order List as XMLType in
Oracle. The structure looks roughly as -
<polist>
<po>
<customer>
<lineitems>
<lineitem>
<item>
<price>
<quantity>
So my polist has multipe po's and each po's has multipe items.
Now, I want to perform following xpath query -
- /polist/po/lineitems/lineitem/item[price="$100"]
In other words, find me an "item with specific price" from list
of all the items in all the po's in my polist.
From what I understand, predicates are not support by XPATH in
Oracle. How can I achieve this using SQL & Extract/exist ?
Any thoughts ??
--NarenSteve:
Thanks for your response. Your solution works !! BTW, your book
has been very handy in my work.
Now, I am taking the same PO and trying to store it into
seperate tables. My document structure is similar to Example 12-
20 in your book (Oracle XML Applications) - department with
several employees. In my case, I have a purchase order with
several lineitems.
Essentially, I followed the example and got the code (written by
you) from Oreilly website to make it work with my example. Now
the problem is when I use putXML to save, the first level gets
saved with no problem.
So, as shown in the snippet below -
>>>>
<?xml version="1.0" encoding='UTF-8'?>
<ROWSET>
<ROW>
<PO_ID>10</PO_ID>
<LINEITEMS>
<LINEITEM>
<ID>7782</ID>
<PRICE>100</PRICE>
<TAXRATE>24</TAXRATE>
<QUANTITY>20</QUANTITY>
<DISCOUNT>10</DISCOUNT>
</LINEITEM>
>>>>
If I don't include the "LINEITEM" data, the instead of trigger
fires properly and the PO_ID makes it to the po_table when I
use "putXML" utility.
BTW, I modeled everything like example 12-20 - po_table,
lineitem_table, lineitem_type, lineitem_list, instead of
trigger, po_view, etc...
Now, when I try to use the "putXML" to insert data at both
levels - po and lineitem as shown in above snippet of input xml
doc, I get the following exception -
java OracleXML putXML -user "scott/tiger" -fileName bar.xml po_view
oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException:
Non supported character set: oracle-ch
aracter-set-178' encountered during processing ROW element 0.
All prior XML row changes were rolled
back. in the XML document.
at oracle.xml.sql.dml.OracleXMLSave.saveXML
(OracleXMLSave.java:2298)
at oracle.xml.sql.dml.OracleXMLSave.saveXML
(OracleXMLSave.java:2175)
at oracle.xml.sql.dml.OracleXMLSave.insertXML
(OracleXMLSave.java:1264)
at OracleXML.Put_XML(OracleXML.java:467)
at OracleXML.ExecutePutXML(OracleXML.java:389)
at OracleXML.main(OracleXML.java:177)
I tried several variation by changing the encoding in my XML
document to - UTF-8, Unicode, etc..
I am using Oracle 9i (9.0.1.1) on windows 2000.
If you need additional information, please let me know !!
--Naren -
Query on XMLType! URGENT!!!
Please, what the most efficient way to query a xmltype column?
My xml's are 250KB ~ 1.5 MB and my table have over 130.000 records.
I have tried:
1) interMedia -> create index [indexname] on [table] (field) indextype is ctxsys.context parameters ('section group path_section_group')
but results a error on creating...
2) Table Functions, but a enough memory error results...
3) create index on xpath directly, but the repetead tag's are discarded...
I don't know what to do...
Please, help me!!!
Thanks...
MarlonMay be this is of some help -
"compile error in hidden module: clBExevent bulider" error in BW 3.5! -
XPath query rewrite and insertChildXML (10g2): Help?
Hi all,
I have a registered schema for a <log> document. The schema defines an element /log/logData and under that there, /log/logData/data having maxOccurs="unbounded". So the form of documents is
<log>
<logData>
<data>a</data>
<data>b</data>
<data>c</data>
</logData>
</log>
In the schema definition I have enabled "storeArrayAsVArray='true'". The <data> elements are stored in a nested table. Every type is stored object-relationally.
To an instance documen, I add <data> elements so:
UPDATE log SET object_value = insertChildXML(object_value, 'log/logData', 'data', '<data>foo</data>') WHERE existsNode ('/log[@uid="foo"]')
The call succeeds but the problem is that I need to make this call thousands of times. Initiallly the call might take 100 ms, but after a few hundred inserts inserting a single element takes over a second, and the time keeps increasing.
I believe at least part of the problem is that XPath query rewrites are not working for this call.
Following Chapter 6 of Oracle XML DB Developer's Guide, to debug the problem I have switched on
ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
and then every invocation causes:
ORA-19022: XML XPath functions are disabled
indicating that Oracle could not rewrite the query. Then I set
ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192'
to obtain a trace file. Here is a portion of that trace:
*** 2005-10-30 16:54:44.984
*** ACTION NAME:() 2005-10-30 16:54:44.968
*** MODULE NAME:(SQL*Plus) 2005-10-30 16:54:44.968
*** SERVICE NAME:(SYS$USERS) 2005-10-30 16:54:44.968
*** SESSION ID:(137.38364) 2005-10-30 16:54:44.968
NO REWRITE
Reason ==> xseq:not optuop
NO REWRITE
Reason ==> xseq:not optuop
NO REWRITE
Reason ==> not SQLX operand
NO REWRITE
Reason ==> non sqlx expression input
NO REWRITE
Reason ==> non rewritable sqlx input
NO REWRITE
(the rest of the file repeats these lines)
I have no idea how to interpet that! Can anyone out there offer some insight/assistance?
Thanks if you can,
HughBelow is a complete example script. Cannot seem to get rewrite for even this simple case. By that I mean, executing both of the SELECT statements near the end yield the ORA-19022, and that executing the insertChildXML takes progressively longer to execute the more child elements there are.
Any pointers appreciated!
Hugh
set echo on
ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192';
exec dbms_xmlschema.deleteSchema('http://hughw.net/foo', dbms_xmlschema.DELETE_CASCADE_FORCE);
begin
dbms_xmlschema.registerSchema('http://hughw.net/foo', XMLType('<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://hughw.net/foo" xmlns="http://hughw.net/foo" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="root" xdb:defaultTable="ROOT" >
<xs:complexType xdb:SQLType="ROOT_T">
<xs:sequence>
<!-- could use out of line storage -->
<!-- commented out
<xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
xdb:SQLName="CHILDREN"
xdb:SQLInline="false" xdb:defaultTable="CHILD"
/>
-->
<!-- use nested table -->
<xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
xdb:SQLName="CHILDREN"
xdb:SQLCollType="CHILD_V"
/>
</xs:sequence>
<xs:attribute name="uid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:complexType name="childType" xdb:SQLType="CHILD_T">
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:schema>'));
end;
insert into root values( XMLType('<?xml version="1.0" encoding="UTF-8"?>
<root uid="1" xmlns="http://hughw.net/foo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://hughw.net/foo http://hughw.net/foo">
<child>a</child>
<child>b</child>
<child>c</child>
</root>'));
CREATE INDEX ROOT_INDEX ON ROOT (extractValue(object_value,'/root/@uid'));
select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial'));
select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial')); -
XPATH query behaves differently depending on presence of default namespace
I'm curious to know why an XPATH query seems to behave differently depending on whether the default namespace is present in the query.
My test case is as follows:
I use a table called xml_messages (id number, message xmltype) containing two rows - one where xmlns is specified and the other without.
1. Default namespace is specified:
<?xml version="1.0"?>
<Bereken xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Fout="false" Identifier="21-4-2008 12:55:02" xmlns="http://schemas.myco.nl/services/IPP">
<Reglementen>
<Reglement Ind="21000005" dlnsts="6">
<Producten>
<Product Ind="1002" ogr="27098.00" bbr="27098.00" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1032" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1052" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1062" ogr="0" bbr="2389.968" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3002" ogr="18968.00" bbr="5690.4" igl="0" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3032" ogr="0" bbr="0" igl="0" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3502" ogr="2845.00" bbr="2845.00" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="5002" ogr="3794.00" bbr="3794.00" igl="0" elt="18" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7502" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7503" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="8101" ogr="0" bbr="0" igl="65" elt="65" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7002" ogr="0" bbr="8724.6" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7202" ogr="0" bbr="0" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7302" ogr="0" bbr="0" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
</Producten>
</Reglement>
</Reglementen>
<Parameters gbtd="1957-12-18T00:00:00.0000000+01:00" gsl="Vrouw" pdr="2008-03-01T00:00:00.0000000+01:00" hdgs="40000" ptp="100" />
</Bereken>
2. No default namespace specified:
<?xml version="1.0"?>
<Bereken xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Fout="false" Identifier="21-4-2008 12:55:02" >
<Reglementen>
<Reglement Ind="21000005" dlnsts="6">
<Producten>
<Product Ind="1002" ogr="27098.00" bbr="27098.00" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1032" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1052" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="1062" ogr="0" bbr="2389.968" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3002" ogr="18968.00" bbr="5690.4" igl="0" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3032" ogr="0" bbr="0" igl="0" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="3502" ogr="2845.00" bbr="2845.00" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="5002" ogr="3794.00" bbr="3794.00" igl="0" elt="18" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7502" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7503" ogr="0" bbr="0" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="8101" ogr="0" bbr="0" igl="65" elt="65" pgs="63758.00" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7002" ogr="0" bbr="8724.6" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7202" ogr="0" bbr="0" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
<Product Ind="7302" ogr="0" bbr="0" igl="65" elt="130" pgs="0" slt="65" plt="0" reg="0" orf="0" />
</Producten>
</Reglement>
</Reglementen>
<Parameters gbtd="1957-12-18T00:00:00.0000000+01:00" gsl="Vrouw" pdr="2008-03-01T00:00:00.0000000+01:00" hdgs="40000" ptp="100" />
</Bereken>
Next, I use the following two queries to get attribute values from the xml messages:
First query using xmlns:
select extractvalue(value(v),'/Product/@Ind' ) ind
, extractvalue(value(v),'/*/@Ind' ) ind2
from xml_messages f
, TABLE(XMLSequence( extract(f.message
,'/Bereken/Reglementen/Reglement/Producten/Product'
,'xmlns="http://schemas.myco.nl/services/IPP"'
))) v
where f.id = 1; -- Selects from the xmltype message that does have xmlns specified
This returns (as the first row)
IND IND2
____ 1002
^
|------ Nothing is returned by the XPATH /Product/@Ind
Second without using xmlns
select extractvalue(value(v),'/Product/@Ind' ) ind
, extractvalue(value(v),'/*/@Ind' ) ind2
from xml_messages f
, TABLE(XMLSequence( extract(f.message
,'/Bereken/Reglementen/Reglement/Producten/Product'
))) v
where f.id = 2; -- Selects from the xmltype message that has no xmlns
This returns (as the first row)
IND IND2
1002 1002
According to XMLSpy, the correct XPATH to get the "Ind" attribute is "/Product/@Ind" so what I dont understand is why query one doesnt return any data when using a default namespace.
The XPATH "/*/@Ind" works in both cases and can be used as a workaround, but it seems less elegant than using the proper XPATH.
I've tried this test case in 9i and 10g, in sqlplus and TOAD, with the same results in all cases.
Can anyone provide some insight as to why this behavior occurs?Thanks, A_Non,
adding the third parm to the extractvalue part of the query works.
ie:
select extractvalue(value(v),'/Product/@Ind', 'xmlns="http://schemas.myco.nl/services/IPP"' ) ind
, extractvalue(value(v),'/*/@Ind' ) ind2
from xml_messages f
, TABLE(XMLSequence( extract(f.message
,'/Bereken/Reglementen/Reglement/Producten/Product'
,'xmlns="http://schemas.myco.nl/services/IPP"'
))) v
where f.id = 1;
I had not expected this because I thought the xml fragment returned by the extract didnt include the default namespace.
However, when looking at the query in more detail, its clear Oracle automatically includes the xmlns part in the returned xml fragment.
One of the rows in the xml fragment:
<Product xmlns="http://schemas.myco.nl/services/IPP" Ind="1002" ogr="27098.00" bbr="27098.00" igl="65" elt="130" pgs="63758.00" slt="65" plt="0" reg="0" orf="0"/> -
How to use one query against multiple table and recieve one report?
I have duplicate tables, (except for their names of course) with commodities prices. They have the same column headings, but the data is different of course. I have a query that gives me a certain piece of information I am looking for but now I need to run this query against every table. I will do this every day as well, to see if the buying criteria is met. There are alot of tables though (256). Is there a way to say run query in all tables and return the results in one place? Thanks for your help.
hey
a. the all 256 tables whuld be one big partitoned table
b. you can use all_tables in order to write a select that will write the report for you:
SQL> set head off
SQL> select 'select * from (' from dual
2 union all
3 select 'select count(*) from ' || table_name || ' union all ' from a
4 where table_name like 'DB%' AND ROWNUM <= 3
5 union all
6 select ')' from dual;
select * from (
select count(*) from DBMS_LOCK_ALLOCATED union all
select count(*) from DBMS_ALERT_INFO union all
select count(*) from DBMS_UPG_LOG$ union all
remove the last 'union all', and tun the generated quary -
SQL> set head on
SQL> select * from (
2 select count(*) from DBMS_LOCK_ALLOCATED union all
3 select count(*) from DBMS_ALERT_INFO union all
4 select count(*) from DBMS_UPG_LOG$
5 );
COUNT(*)
0
0
0
Amiel -
Best practice for a same query against 2 different tables
Hello all,
I want to extract info about tablespaces storage, both permanent and temporary. For that I use 2 different cursors that do exactly the same query but against a different table (dba_data_files and dba_temp_files).
CURSOR permanentTBSStorageInfo (tablespaceName VARCHAR2) IS
SELECT file_name, bytes, autoextensible, maxbytes, increment_by
FROM dba_data_files
WHERE tablespace_name = tablespaceName;
CURSOR temporaryTBSStorageInfo (tablespaceName VARCHAR2) IS
SELECT file_name, bytes, autoextensible, maxbytes, increment_by
FROM dba_temp_files
WHERE tablespace_name = tablespaceName;
First I'm bothered that I have to use 2 cursors to execute the same query against 2 different tables. Is there no another way around?
Then I fetch the results of this cursors in 2 different loops because I didn't find a way to dynamically call the cursors. I am looking for best practice here, knowing that I will do the same parsing against the results of the 2 cursors.
Thank you,Hi
Check whether the below query is helpful or not
select fs.tablespace_name "Tablespace",
fs.tempspace "Temp MB",
df.totalspace "Total MB"
from
(select
tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from
dba_data_files
group by
tablespace_name
) df,
(select
tablespace_name,
round(sum(bytes) / 1048576) tempSpace
from
dba_temp_files
group by
tablespace_name
) fs
where
df.tablespace_name = fs.tablespace_name;
Thanks -
Error when running a query against Multiprovider using 0FIGL_VC1
Hi SAP Gurus,
I'm creating a MultiProvider for FI-GL.It has 2 Cubes.one is 0FIGL_VC1 (Virtual Cube) and other one is Customised Cube.When I run Query against this MultiProvider with the combination of basic cubes key figures,I'm getting an error
'Abort system error in Program SAPLRSDRC and Form RSDRC/Form DISPATCHER/RECEIV '
then system gets disconnected from the Server .
Please give me the solution to fix it & I'll assign the points .
Thanks & Regards
RajaHello Suman,
Check the table rszglobv for this variable - ZCONLEH.
If it is available there then see which infoobject it belongs to and then look for that in the query designer. May be resaving the query solves the issue.
If the variable is not available in the table, then it seems that the variable is lost and you might have to recreate it for keeping the semantics of the query the same as it was before the upgrade.
Regards,
Shweta -
Query against materialized view from stored procedure brings back empty row
I have a stored procedure that runs a query against a materialized view. When I run the query outside the SP it works just fine. When I change the MV to a table name, the SP works. When I change it back to the MV i get an empty row. Any ideas? The code is below:
PROCEDURE getAuth (p_naid IN NUMBER,
p_scope IN VARCHAR2,
o_xml_data OUT SYS_REFCURSOR
) IS
BEGIN
IF p_scope = 'Approved' THEN
OPEN o_xml_data FOR
SELECT naid,
p_naid,
auth_type,
xml_data
FROM some_mv
WHERE naid = p_naid;
RETURN;
CLOSE o_xml_data;
... the rest of the procedure ...does procedure contain EXCEPTION handler?
if so, then remove, delete & eliminate EXCEPTION handler (at least during testing & debugging)
Maybe you are looking for
-
How to Add Cisco 861's behind ASA 5505
I will be setting up a VPN with a client soon. They are shipping 2 Cisco 861's that are planning to go behind our ASA 5505. They are set up to be NATed. I am trying to understand what the best way to do this would be as I seem to keep running into
-
How to restore Address Book and then add working iCloud Account?
OK i'm going insane trying to resolve this one.... all started with a shed load of Duplicates! 3 devices: MacBook Pro, iMac, iPhone 4S I finally upgraded the MBP to 10.7.2, the iMac already was and the iPhone was already 5.0.1 I've held off moving t
-
I would like to set up port forwarding on my Extreme so that I can access my SlingBox from work. My problem is that I can't find where to do this in Manual setup. I know I've seen it before and should be in the advanced section but it's no longer the
-
How do i share itunes on all my devices?
I have an ipod touch and I got some itunes credits loaded there and so is my ipad, now i got an iphone and i wanted to buy something using that itunes credits, what can i do to use that?
-
My cat tends to try to lie across my laptop keyboard, but I use the external bluetooth one would love it if there was a software program that would notice the exernal one and turn off the internal one.