本文介绍了如何在Oracle XMLTable中将XPath与变量一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Oracle XMLTable()中将XPath与诸如'/abc/[contract = $ count]/initialValue'这样的变量一起使用?
How to use XPath with a variable like this '/abc/[contract = $count]/initialValue' in Oracle XMLTable() ?
例如:
XMLTable('root/level1', PASSING xmlContent
COLUMNS initial_value varchar2(100) PATH '/abc/[contract = $count]/initialValue'
)
如何替换/评估$ count运行时?
How to substitute/evaluate $count runtime ?
推荐答案
您可以传入变量,只需在传递子句中定义变量即可:
You can pass variables in, just define them in your passing clause:
with table1 AS
(select xmltype(
'<abc>
<def>
<contract>1</contract>
<oper>SFO</oper>
<lmt>limit1</lmt>
</def>
<def>
<contract>2</contract>
<oper>boston</oper>
<lmt >limit2</lmt>
</def>
</abc>'
) xmlcol from dual
)
SELECT u.*
FROM table1
, XMLTable('/abc/def[contract = $count]'
PASSING xmlcol, 1 as "count"
COLUMNS contract integer path 'contract',
oper VARCHAR2(20) PATH 'oper' ) u
CONTRACT OPER
---------- --------------------
1 SFO
这篇关于如何在Oracle XMLTable中将XPath与变量一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!