我有一個表在Oracle XDB中有一行稱爲測試。Xquery鑄造迄今不返回行
SQL> select * from test;
SYS_NC_ROWINFO$
---------------------------
<Employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="">
<location>
<joiningDate id="onsite">
<hireDate>2012-06-18</hireDate>
</joiningDate>
<joiningDate id="offshore">
<hireDate>2011-07-8</hireDate>
</joiningDate>
</location>
</Employee>
消逝:00:00:00.00
我也有喜歡
CREATE INDEX test_xml_index ON test (OBJECT_VALUE)
INDEXTYPE IS XDB.XMLIndex PARAMETERS ('PATH TABLE test_dates_tab');
BEGIN
DBMS_XMLINDEX.registerParameter(
'myprop',
'ADD_GROUP GROUP test_dates
XMLTable test_dates_tab ''/Employee''
XMLNAMESPACES (''http://www.w3.org/2001/XMLSchema-instance'' AS "xsi")
COLUMNS onsite date PATH ''.//*[@id="onsite"]/hireDate/text()''
');
END;
/
爲什麼我的查詢沒有返回空值的指數?
SQL> select x.*
2 from test t,
3 xmltable(
4 xmlnamespaces(
5 'http://www.w3.org/2001/XMLSchema-instance' as "xsi"
6 ),
7 'for $d in /Employee/location
8 where $d/joiningDate[@id="onsite"]/hireDate/text() = xs:date("2012-06-18")
9 return $d'
10 passing t.object_value
11 columns
12 hiredate date path 'hireDate'
13 ) as x
14
SQL>/
HIREDATE
--------------------
在您的幫助延
select x.*
from test t,
xmltable(
xmlnamespaces(
'http://www.w3.org/2001/XMLSchema-instance' as "xsi"
),
'for $d in /Employee/location
where $d/joiningDate[@id="onsite"]/hireDate/text() = xs:date("2012-06-18")
return $d'
passing t.object_value
columns
hiredate date path 'joiningDate[@id="onsite"]/hireDate'
) as x
不要在您的問題中更改原始查詢以包含修正;現在看起來沒有什麼是錯的,接受的答案沒有意義,除非你回頭看看編輯歷史。 –