隐藏的系统间 - sqlStorage
Intersystems caché - sqlStorage
我需要将我的全局映射到 sql。我有这样的全局结构:
^myGlob("mltab","main","Dta",idRow,idCol,"Index")
具体来说:
^myGlob("mltab","main","Dta",3,1) = 20
^myGlob("mltab","main","Dta",3,2) = 30
^myGlob("mltab","main","Dta",3,2,"Index") = "t|1320|30|62913"
^myGlob("mltab","main","Dta",3,3) = "01.04.2013"
^myGlob("mltab","main","Dta",3,4) = 36
^myGlob("mltab","main","Dta",3,5) = 166.8
^myGlob("mltab","main","Dta",4,1) = 20
^myGlob("mltab","main","Dta",4,2) = 30
^myGlob("mltab","main","Dta",4,3) = "01.04.2013"
^myGlob("mltab","main","Dta",4,4) = 36
^myGlob("mltab","main","Dta",4,4,"Index") = "nextIndexVal"
^myGlob("mltab","main","Dta",4,5) = 166.8
.
.
.
"mltab"
、"main"
、"Dta"
和 "Index"
是常量。 idRow
是我的主键,idCol
对我来说不重要,但给我带来了问题,因为它可以改变。
我需要得到一些像 colId=2^index="t|1320|30|62913" 值到一些 table 列(地图 class 属性).我映射的其他值。
我当前的代码如下所示:
Class Kza.NewClass1 Extends %Persistent [ Not ProcedureBlock, StorageStrategy = MySqlStorageStrategy ]
{
Property hyperlink As %String;
Property colId As %String;
Property id As %Integer;
Property prop1 As %String;
Property prop2 As %String;
Property prop3 As %String;
Property prop4 As %String;
Property prop5 As %String;
Index MyIndex1 On id [ IdKey, PrimaryKey, Unique ];
<Storage name="MySqlStorageStrategy">
<ExtentSize>100000</ExtentSize>
<SQLMap name="Map1">
<Global>^myGlob</Global>
<RowIdSpec name="1">
<Expression>{L2}</Expression>
<Field>id</Field>
</RowIdSpec>
<Subscript name="1">
<Expression>{id}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{colId}</Expression>
</Subscript>
<Type>index</Type>
</SQLMap>
<SQLMap name="MyMasterMap">
<ConditionalWithHostVars></ConditionalWithHostVars>
<Data name="colId">
<Node>6</Node>
</Data>
<Data name="hyperlink">
<Node>"Index"</Node>
</Data>
<Data name="prop1">
<Node>1</Node>
</Data>
<Data name="prop2">
<Node>2</Node>
</Data>
<Data name="prop3">
<Node>3</Node>
</Data>
<Data name="prop4">
<Node>4</Node>
</Data>
<Data name="prop5">
<Node>5</Node>
</Data>
<Global>^myGlob</Global>
<RowIdSpec name="1">
<Expression>{L1}</Expression>
<Field>id</Field>
</RowIdSpec>
<Subscript name="1">
<Expression>"mltab"</Expression>
</Subscript>
<Subscript name="2">
<Expression>"main"</Expression>
</Subscript>
<Subscript name="3">
<Expression>"Dta"</Expression>
</Subscript>
<Subscript name="4">
<Expression>{id}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^Kza.testToTable1S</StreamLocation>
<Type>%CacheSQLStorage</Type>
</Storage>
}
我想我的问题可能出在数据节点定义上:
<Data name="colId">
<Node>6</Node>
</Data>
<Data name="hyperlink">
<Node>"Index"</Node>
</Data>
但遗憾的是,我对这个问题还不够熟悉...所以有人可以帮助我在我的 sql table 中获取列 hyperlink
的值为 colId=2^index=t|1320|30|62913
在 ID 为 3 的行和 colId=4^index=nextIndexVal
在行 ID 4?
如果超链接的colId 属性 固定了,你可以使用标签RetrievalCode 写一些COS 代码,如果不固定,你可以写一些用于检索colId 然后像这里一样
<Data name="hyperlink">
<RetrievalCode> s {hyperlink}=$g(^myGlob("mltab","main","Dta",{L4},2,"Index"))
</RetrievalCode>
</Data>
你的 RowIdSpec 可能是错误的,因为,属性 id 在 4 级下标上,所以你使用 L4 来表达。
<RowIdSpec name="1">
<Expression>{L4}</Expression>
<Field>id</Field>
</RowIdSpec>
和最新变体
<Data name="colId">
<RetrievalCode>s {*}="" f { s {*}=$o(^myGlob({L1},{L2},{L3},{L4},{*})) quit:{*}="" quit:$d(^myGlob({L1},{L2},{L3},{L4},{*},"Index"))}
</RetrievalCode>
</Data>
<Data name="hyperlink">
<RetrievalCode>s colId="" f { s colId=$o(^myGlob({L1},{L2},{L3},{L4},colId)) quit:colId="" quit:$d(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))}
s {*}=$g(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))
</RetrievalCode>
</Data>
<Data name="hyperlink2">
<RetrievalCode>s colId="" f { s colId=$o(^myGlob({L1},{L2},{L3},{L4},colId)) quit:colId="" quit:$d(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))}
s {*}="colId="_colId_"^index="""_$g(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))_""""
</RetrievalCode>
</Data>
SQLMap存储中的这段代码做的:
<Data name="hyperlink">
<RetrievalCode>
<![CDATA[set res=""
set colId=""
for
{
set colId = $order( ^myGlob("mltab","main","Dta",{L4},colId) )
quit:(colId = "")
set indexTab = $g(^myGlob("mltab","main","Dta",{L4},colId,"Index"))
if indexTab'="" {
set res = res_"colId="_colId_"index="_indexTab
}
}
s {hyperlink}=res]]></RetrievalCode>
</Data>
{L4}为row id,SQLmap不超过1个
我需要将我的全局映射到 sql。我有这样的全局结构:
^myGlob("mltab","main","Dta",idRow,idCol,"Index")
具体来说:
^myGlob("mltab","main","Dta",3,1) = 20
^myGlob("mltab","main","Dta",3,2) = 30
^myGlob("mltab","main","Dta",3,2,"Index") = "t|1320|30|62913"
^myGlob("mltab","main","Dta",3,3) = "01.04.2013"
^myGlob("mltab","main","Dta",3,4) = 36
^myGlob("mltab","main","Dta",3,5) = 166.8
^myGlob("mltab","main","Dta",4,1) = 20
^myGlob("mltab","main","Dta",4,2) = 30
^myGlob("mltab","main","Dta",4,3) = "01.04.2013"
^myGlob("mltab","main","Dta",4,4) = 36
^myGlob("mltab","main","Dta",4,4,"Index") = "nextIndexVal"
^myGlob("mltab","main","Dta",4,5) = 166.8
.
.
.
"mltab"
、"main"
、"Dta"
和 "Index"
是常量。 idRow
是我的主键,idCol
对我来说不重要,但给我带来了问题,因为它可以改变。
我需要得到一些像 colId=2^index="t|1320|30|62913" 值到一些 table 列(地图 class 属性).我映射的其他值。
我当前的代码如下所示:
Class Kza.NewClass1 Extends %Persistent [ Not ProcedureBlock, StorageStrategy = MySqlStorageStrategy ]
{
Property hyperlink As %String;
Property colId As %String;
Property id As %Integer;
Property prop1 As %String;
Property prop2 As %String;
Property prop3 As %String;
Property prop4 As %String;
Property prop5 As %String;
Index MyIndex1 On id [ IdKey, PrimaryKey, Unique ];
<Storage name="MySqlStorageStrategy">
<ExtentSize>100000</ExtentSize>
<SQLMap name="Map1">
<Global>^myGlob</Global>
<RowIdSpec name="1">
<Expression>{L2}</Expression>
<Field>id</Field>
</RowIdSpec>
<Subscript name="1">
<Expression>{id}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{colId}</Expression>
</Subscript>
<Type>index</Type>
</SQLMap>
<SQLMap name="MyMasterMap">
<ConditionalWithHostVars></ConditionalWithHostVars>
<Data name="colId">
<Node>6</Node>
</Data>
<Data name="hyperlink">
<Node>"Index"</Node>
</Data>
<Data name="prop1">
<Node>1</Node>
</Data>
<Data name="prop2">
<Node>2</Node>
</Data>
<Data name="prop3">
<Node>3</Node>
</Data>
<Data name="prop4">
<Node>4</Node>
</Data>
<Data name="prop5">
<Node>5</Node>
</Data>
<Global>^myGlob</Global>
<RowIdSpec name="1">
<Expression>{L1}</Expression>
<Field>id</Field>
</RowIdSpec>
<Subscript name="1">
<Expression>"mltab"</Expression>
</Subscript>
<Subscript name="2">
<Expression>"main"</Expression>
</Subscript>
<Subscript name="3">
<Expression>"Dta"</Expression>
</Subscript>
<Subscript name="4">
<Expression>{id}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^Kza.testToTable1S</StreamLocation>
<Type>%CacheSQLStorage</Type>
</Storage>
}
我想我的问题可能出在数据节点定义上:
<Data name="colId">
<Node>6</Node>
</Data>
<Data name="hyperlink">
<Node>"Index"</Node>
</Data>
但遗憾的是,我对这个问题还不够熟悉...所以有人可以帮助我在我的 sql table 中获取列 hyperlink
的值为 colId=2^index=t|1320|30|62913
在 ID 为 3 的行和 colId=4^index=nextIndexVal
在行 ID 4?
如果超链接的colId 属性 固定了,你可以使用标签RetrievalCode 写一些COS 代码,如果不固定,你可以写一些用于检索colId 然后像这里一样
<Data name="hyperlink">
<RetrievalCode> s {hyperlink}=$g(^myGlob("mltab","main","Dta",{L4},2,"Index"))
</RetrievalCode>
</Data>
你的 RowIdSpec 可能是错误的,因为,属性 id 在 4 级下标上,所以你使用 L4 来表达。
<RowIdSpec name="1">
<Expression>{L4}</Expression>
<Field>id</Field>
</RowIdSpec>
和最新变体
<Data name="colId">
<RetrievalCode>s {*}="" f { s {*}=$o(^myGlob({L1},{L2},{L3},{L4},{*})) quit:{*}="" quit:$d(^myGlob({L1},{L2},{L3},{L4},{*},"Index"))}
</RetrievalCode>
</Data>
<Data name="hyperlink">
<RetrievalCode>s colId="" f { s colId=$o(^myGlob({L1},{L2},{L3},{L4},colId)) quit:colId="" quit:$d(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))}
s {*}=$g(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))
</RetrievalCode>
</Data>
<Data name="hyperlink2">
<RetrievalCode>s colId="" f { s colId=$o(^myGlob({L1},{L2},{L3},{L4},colId)) quit:colId="" quit:$d(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))}
s {*}="colId="_colId_"^index="""_$g(^myGlob({L1},{L2},{L3},{L4},colId,"Index"))_""""
</RetrievalCode>
</Data>
SQLMap存储中的这段代码做的:
<Data name="hyperlink">
<RetrievalCode>
<![CDATA[set res=""
set colId=""
for
{
set colId = $order( ^myGlob("mltab","main","Dta",{L4},colId) )
quit:(colId = "")
set indexTab = $g(^myGlob("mltab","main","Dta",{L4},colId,"Index"))
if indexTab'="" {
set res = res_"colId="_colId_"index="_indexTab
}
}
s {hyperlink}=res]]></RetrievalCode>
</Data>
{L4}为row id,SQLmap不超过1个