Question

First I apologise for the lengh of this question.. I have a global set up in the following manner:

^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"

The first subscript is an internal Hmo, the sceond is an internal provide, the third is a line number and the last is a line detail number. The data at the 4th subscript level is a combined audit trail history of the line with the highest line detail number being the current line.

I have 3 classes set-up with parent child relationships as follows: The main class

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>
}

The 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>
}

The Line Detail Class Class XFXA.Try3.IppProvLineDetail Extends (%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>
}

When the user marks a line for deletion, a deleted flag is set to 1 in the current detail line at the 4th subscript level AND if this line is not the last line, the filing code moves to be the last line. If I try to do this in a delete method from my main class, I get an error message that says Updating RowIds is not allowed. this is because I tried to manipulate the Line property of the line class moving lines around to push the deleted one to the end. A check of the documentation found AllowRowIDUpdate with some warnings but not clear example of how to use it. Does anyone know of a way to accomplish this?

Was it helpful?

Solution

Well, the documentation on AllowRowIDUpdate says

"Set to 1 only if you are doing your own filing in a BEFORE trigger and using the %SkipFiling flag. Otherwise, use the default of 0".

If you do your own filing in a BEFORE trigger and using the %SkipFiling flag then you mostly aren't using SQL Storage to store the data, you are just exposing your own storage so that it can be used via SQL.

I would suggest that the easiest thing to do would be to not update RowIDs. Instead of using update, use insert and delete to move the lines. This is essentially the same thing you would have to do using straight global access, since you can't update subscripts, per se, either.

Also, it's out of the scope of your question, but do I would consider different storage if I could. Moving line numbers around so there are no gaps doesn't seem to accomplish much when the line numbers are really stored in some kind of BTree like structure anyway, so maybe you could just leave gaps?

OTHER TIPS

It's almost always better to use a synthetic/surrogate key that doesn't need to change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top