xml 自定义类InterSystemsCaché的查询示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 自定义类InterSystemsCaché的查询示例相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="Utils.CustomQuery">
<Super>%Persistent,%Populate</Super>
<TimeCreated>63869,45310.24869</TimeCreated>

<Property name="Prop1">
<Type>%String</Type>
</Property>

<Property name="Prop2">
<Type>%Integer</Type>
</Property>

<Query name="AllRecords">
<Type>%Query</Type>
<SqlName>AllRecords</SqlName>
<SqlProc>1</SqlProc>
<Parameter name="CONTAINID" value="1"/>
<Parameter name="ROWSPEC" value="Id:%String,Prop1:%String,Prop2:%Integer"/>
</Query>

<Method name="AllRecordsExecute">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	Set qHandle = ""
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllRecordsFetch">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,&Row:%List,&AtEnd:%Integer=0]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	#; Iterating through ^Utils.CustomQueryD
	#; Writing the next id to qHandle and writing the global's value with the new id into val
	Set qHandle = $Order(^Utils.CustomQueryD(qHandle),1,val)
	#; Checking whether there is any more data left   
	If qHandle = "" {
		Set AtEnd = 1
		Set Row = ""
		Quit $$$OK
	}
	#; If not, create %List 
	#; val = $Lb("", Prop1, Prop2) see Storage definition 
	#; Row =$lb(Id,Prop1, Prop2) see ROWSPEC for the AllRecords request
	Set Row = $Lb(qHandle, $Lg(val,2), $Lg(val,3))
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllRecordsClose">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	Kill qHandle
	Quit $$$OK
]]></Implementation>
</Method>

<Query name="AllStatic">
<Type>%Query</Type>
<SqlName>AllStatic</SqlName>
<SqlProc>1</SqlProc>
<Parameter name="CONTAINID" value="1"/>
<Parameter name="ROWSPEC" value="Id:%String,Prop1:%String,Prop2:%Integer"/>
</Query>

<Method name="AllStaticExecute">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	&sql(	DECLARE C CURSOR FOR
		    SELECT Id, Prop1, Prop2
		    FROM Utils.CustomQuery)

 	&sql(OPEN C)
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllStaticFetch">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,&Row:%List,&AtEnd:%Integer=0]]></FormalSpec>
<PlaceAfter>AllStaticExecute</PlaceAfter>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	&sql(FETCH C INTO :Id, :Prop1, :Prop2)
	#; Checking whether there is any more data left      
	If (SQLCODE'=0) {
		Set AtEnd = 1
		Set Row = ""
		Quit $$$OK
	}
	Set Row = $Lb(Id, Prop1, Prop2)
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllStaticClose">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<PlaceAfter>AllStaticFetch</PlaceAfter>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	&sql(CLOSE C)
	Quit $$$OK
]]></Implementation>
</Method>

<Query name="AllDynamic">
<Type>%Query</Type>
<SqlName>AllDynamic</SqlName>
<SqlProc>1</SqlProc>
<Parameter name="CONTAINID" value="1"/>
<Parameter name="ROWSPEC" value="Id:%String,Prop1:%String,Prop2:%Integer"/>
</Query>

<Method name="AllDynamicExecute">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	Set qHandle = ##class(%SQL.Statement).%ExecDirect(,"SELECT * FROM Utils.CustomQuery")
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllDynamicFetch">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,&Row:%List,&AtEnd:%Integer=0]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	If qHandle.%Next()=0 {
		Set AtEnd = 1
		Set Row = ""
		Quit $$$OK
	} 

	Set Row = $Lb(qHandle.%Get("Id"), qHandle.%Get("Prop1"), qHandle.%Get("Prop2"))
	Quit $$$OK
]]></Implementation>
</Method>

<Method name="AllDynamicClose">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	Kill qHandle
	Quit $$$OK
]]></Implementation>
</Method>

<Storage name="Default">
<Type>%Library.CacheStorage</Type>
<DataLocation>^Utils.CustomQueryD</DataLocation>
<DefaultData>CustomQueryDefaultData</DefaultData>
<IdLocation>^Utils.CustomQueryD</IdLocation>
<IndexLocation>^Utils.CustomQueryI</IndexLocation>
<StreamLocation>^Utils.CustomQueryS</StreamLocation>
<ExtentSize>1000</ExtentSize>
<Data name="CustomQueryDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Prop1</Value>
</Value>
<Value name="3">
<Value>Prop2</Value>
</Value>
</Data>
<Property name="%%CLASSNAME">
<Selectivity>0.1000%</Selectivity>
<OutlierSelectivity>.992632:</OutlierSelectivity>
</Property>
<Property name="Prop1">
<Selectivity>0.1000%</Selectivity>
</Property>
<Property name="Prop2">
<Selectivity>0.1000%</Selectivity>
</Property>
<SQLMap name="IDKEY">
<BlockCount>-12</BlockCount>
</SQLMap>
</Storage>
</Class>
</Export>

以上是关于xml 自定义类InterSystemsCaché的查询示例的主要内容,如果未能解决你的问题,请参考以下文章

InterSystemsCaché:如何计算表中列表中值的遭遇? [关闭]

如何为自定义 XML 格式定义类结构

Android XML中引用自定义内部类view的四个why

android中 自定义了一个MyView(继承自View类) 在xml布局文件中作为组件添加(无错误提示)但运行后报错

android xml引用不到自定义的view类。 类名包名都正确。

自定义类库:Java转换xml文件转化pojo工具