嵌套for循环中的Xquery where子句

时间:2016-12-04 11:13:03

标签: xquery xbase

我需要在嵌套的FLWOR语句中引用2个xml文档。

MJH source.xml

<data-set>
 <record>
 <table>CONTACT</table>
 <column>AGGREGATE_REPORT</column>
 <change>Dropped</change>
 <logic>Related to agCenter</logic>
 </record>
<record>
 <table>QNR_DESIGN_TEMPLATE</table>
 <column>LOGO1</column>
 <change>Dropped</change>
 <logic>Related to agCenter</logic>
</record>
</data-set>

这是外部文件,我需要提取表格&#39;和&#39;列&#39;每行的值。

MVReport - 包含SQL语句的报告文档的集合。

....
<xml-property name="queryText"><![CDATA[select v.*
from poi_visit_details_v v
where v.site_id=? 
and v.std_code_id in ('15', 'TelephoneMonitoringVisit')
and to_char(v.actual_visit_date, 'yyyy-mm-dd') = substr(?, 0, 10)
and (reports_access_pk.site_access(v.SITE_ID, ?) = 'Y'
or reports_access_pk.superuser_access(?) = 'Y')
]]></xml-property>
<xml-property name="queryText"><![CDATA[select v.*
from poi_visit_details_v v
where v.site_id=? 
and v.std_code_id in ('15', 'TelephoneMonitoringVisit')
and to_char(v.actual_visit_date, 'yyyy-mm-dd') = substr(?, 0, 10)
and (reports_access_pk.site_access(v.SITE_ID, ?) = 'Y'
or reports_access_pk.superuser_access(?) = 'Y')
]]></xml-property>

...

这个集合是内部循环,我需要找到包含单词&#34; select&#34;的所有SQL语句。以及&#39;表&#39;,&#39;列&#39;从外循环返回的值。

这是我的xquery。

我遇到的问题是如何引用外表&#39;,&#39;列&#39;内环中的值&#34;其中......和......&#34;条款?

for $target in doc("H:\MJH source.xml")/data-set/record
let $tTable := $target/table
let $tColumn := $target/column
for $sql in collection("MVReport") //*:xml-property[@name = "queryText"]
where $sql contains text "select"
and $sql contains $tTable
and $sql contains $tColumn
let $report := base-uri()
return <report><name>{$sql/base-uri()}</name><sql>{$sql}</sql></report>

感谢您的帮助。

0 个答案:

没有答案