保存使用缓存sql存储的缓存对象时更改RowIds

时间:2012-07-16 19:01:55

标签: intersystems-cache

首先,我为这个问题的长度道歉。 我通过以下方式进行全球设置:

^WHEAIPP(1,116444,1)=3
^WHEAIPP(1,116444,1,1)="58898^^LSWELFER^58898,0"
^WHEAIPP(1,116444,1,2)="58898^59128^MPHILLIPS^59135,0"
^WHEAIPP(1,116444,1,3)="62626^62745^FXALTMAN^62626,58427^^^^^^2^"
^WHEAIPP(1,116444,2)=3
^WHEAIPP(1,116444,2,1)="59129^^MPHILLIPS^59910,0^^^^^^"
^WHEAIPP(1,116444,2,2)="59129^59547^SSNARE^59934,0^^^^^^"
^WHEAIPP(1,116444,2,3)="59129^62954^FXALTMAN^62654,32289^^^^^^3^"
^WHEAIPP(1,116444,3)=4
^WHEAIPP(1,116444,3,1)="60311^^SALFANO^60311,0^^^^^^"
^WHEAIPP(1,116444,3,2)="60311^^SSNARE^60754,0^^^^^^2"
^WHEAIPP(1,116444,3,3)="60311^^NEPAXSON^60757,0^^^^^^2"
^WHEAIPP(1,116444,3,4)="60311^62636^FXALTMAN^62626,58428^=^100^=^25^^5"
^WHEAIPP(1,116444,4)=4
^WHEAIPP(1,116444,4,1)="59548^^SSNARE^59550,0"
^WHEAIPP(1,116444,4,2)="59548^60310^SSNARE^59934,0^^^^^^2"
^WHEAIPP(1,116444,4,3)="62626^^FXALTMAN^62626,61050^^^^^^^1"
^WHEAIPP(1,116444,4,4)="62617^62647^FXALTMAN^62627,27518^^^^^^4"

第一个下标是内部Hmo,sceond是内部提供,第三个是行号,最后一个是行详细号。第4个下标级别的数据是该行的合并审计跟踪历史记录,最高行详细信息编号是当前行。

我有3个类与父子关系设置,如下所示: 主要课程

Class XFXA.Try3.IppProv Extends (%Persistent, %Populate, %XML.Adaptor) [ ClassType =    
  persistent, Inheritance = right, ProcedureBlock, SqlRowIdName = Id, StorageStrategy   
  = SQLMapping ]
{

Property Hmo As %Integer [ Required ];

Property Keen As %Integer [ Required ];

/// Contains the array of data initially loaded into the class
Property OriginalData As %String [ MultiDimensional ];

Property ReadyToFile As %Boolean [ InitialExpression = 0, Transient ];

Relationship IppLines As XFXA.Try3.IppProvLine [ Cardinality = children, Inverse =    
relIppProv ];

Index iMaster On (Hmo, Keen) [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<DataLocation>^[%extRef("UCKE"),%extRef("SYKE")]WHEAIPP</DataLocation>
<ExtentSize>100000</ExtentSize>   
<SequenceNumber>19</SequenceNumber>
<SQLMap name="DBMS">
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{Keen}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvS</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}

Line class

Class XFXA.Try3.IppProvLine Extends (%Persistent, %Populate, %XML.Adaptor) [ ClassType 
= persistent, Inheritance = right, ProcedureBlock, SqlRowIdName = Id, StorageStrategy 
=SQLMapping ]
{

Relationship relIppProv As XFXA.Try3.IppProv [ Cardinality = parent, Inverse = 
IppLines ];

Relationship IppLineDetail As XFXA.Try3.IppProvLineDetail [ Cardinality = children, 
Inverse = relIppProvLinex ];

Property Line As %String;

Property IppLineDetailCount As %String;

Index iMaster On Line [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<ExtentSize>100000</ExtentSize>
<SequenceNumber>14</SequenceNumber>
<SQLMap name="DBMS">
<Data name="IppLineDetailCount">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>1</Piece>
</Data>
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{XFXA_Try3.IppProv.Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{XFXA_Try3.IppProv.Keen}</Expression>
</Subscript>
<Subscript name="3">
<Expression>{Line}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvLineS</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}

线明细班     类XFXA.Try3.IppProvLineDetail扩展(%Persistent,%XML.Adaptor)[ClassType =     persistent,Inheritance = right,ProcedureBlock,SqlRowIdName = Id,StorageStrategy =     SQLMapping]     {

Relationship relIppProvLinex As XFXA.Try3.IppProvLine [ Cardinality = parent, Inverse = 
IppLineDetail ];

Property LnDetail As %String;

Index iMaster On LnDetail [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<ExtentSize>100000</ExtentSize>
<SQLMap name="DBMS">
<Data name="ClmAmtAllowed">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>6</Piece>
</Data>
<Data name="ClmLineAmtAllowed">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>8</Piece>
</Data>
<Data name="ClmLineOp">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>7</Piece>
</Data>
<Data name="ClmOp">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>5</Piece>
</Data>
<Data name="Deleted">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>11</Piece>
</Data>
<Data name="EffDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>1</Piece>
</Data>
<Data name="IppCode">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>10</Piece>
</Data>
<Data name="LastChgDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>4</Piece>
</Data>
<Data name="PxDxCdeFlag">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>9</Piece>
</Data>
<Data name="TermDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>2</Piece>
</Data>
<Data name="UserIni">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>3</Piece>
</Data>
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{XFXA_Try3.IppProv.Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{XFXA_Try3.IppProv.Keen}</Expression>
</Subscript>
<Subscript name="3">
<Expression>{XFXA_Try3.IppProvLine.Line}</Expression>
</Subscript>
<Subscript name="4">
<Expression>{LnDetail}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvLineDetails</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}

当用户标记要删除的行时,在第4个下标级别的当前详细信息行中将删除的标记设置为1,如果该行不是最后一行,则归档代码将移动到最后一行。如果我尝试在我的主类的删除方法中执行此操作,我会收到一条错误消息,指出不允许更新RowIds。这是因为我试图操纵线类移动线的Line属性将被删除的线条推到最后。检查文档时发现AllowRowIDUpdate有一些警告但不清楚如何使用它的示例。有谁知道如何实现这个目标?

2 个答案:

答案 0 :(得分:0)

嗯,AllowRowIDUpdate上的文档说

  

“仅当您在BEFORE触发器中进行自己的归档时才设置为1   并使用%SkipFiling标志。否则,使用默认值0“。

如果您在BEFORE触发器中执行自己的归档并使用%SkipFiling标志,那么您大多数时候不使用SQL存储来存储数据,您只是暴露自己的存储,以便可以通过SQL使用它。 / p>

我建议最简单的做法是不更新RowID。而不是使用更新,使用插入和删除来移动行。这基本上与使用直接全局访问所要做的事情相同,因为您本身也无法更新下标。

此外,它超出了您的问题的范围,但如果可以,我会考虑不同的存储空间。当线号真的存储在某种类似BTree的结构中时,没有间隙似乎没有差距,所以也许你可以留下空白?

答案 1 :(得分:0)

使用不需要更改的合成/代理键几乎总是更好。