我以这种格式在全球范围内拥有数据:
^kza("mltab","TAB","Dta",1,1) = 3341
^kza("mltab","TAB","Dta",1,2) = "First Name"
^kza("mltab","TAB","Dta",1,3) = "type1"
^kza("mltab","TAB","Dta",1,4) = 7400.11
^kza("mltab","TAB","Dta",2,1) = 3614
^kza("mltab","TAB","Dta",2,2) = "Second Name"
^kza("mltab","TAB","Dta",2,3) = "type2"
^kza("mltab","TAB","Dta",2,4) = 7600.11
我的对象类看起来像这样:
Class Kza.Employees Extends %Persistent [ StorageStrategy = EmpStorage ]
{
Property num As %Integer; //unique identifier
Property id As %Integer;
Property num As %Integer;
Property name As %String;
Property type As %String;
Property pay As %Double;
Index NewIndex1 On id [ IdKey, PrimaryKey, Unique ];
<Storage name="EmpStorage">
<ExtentSize>100000</ExtentSize>
<SequenceNumber>8</SequenceNumber>
<SQLMap name="MasterMap">
<ConditionalWithHostVars></ConditionalWithHostVars>
<Data name="num">
<Node>1</Node>
</Data>
<Data name="name">
<Node>2</Node>
</Data>
<Data name="pay">
<Node>4</Node>
</Data>
<Data name="type">
<Node>3</Node>
</Data>
<Global>^kza</Global>
<RowIdSpec name="1">
<Expression>{L1}</Expression>
<Field>id</Field>
</RowIdSpec>
<Subscript name="1">
<Expression>"mltab"</Expression>
</Subscript>
<Subscript name="2">
<Expression>"TAB"</Expression>
</Subscript>
<Subscript name="3">
<Expression>"Dta"</Expression>
</Subscript>
<Subscript name="4">
<Expression>{id}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^Kza.EmployeesS</StreamLocation>
<Type>%CacheSQLStorage</Type>
</Storage>
}
问题在于,如果我这样做
insert into Kza.Employees(id, num, name, pay, type) VALUES(132, 3214, 'Name Second', 89000, 'type5')
结果是:
^kza("mltab","TAB","Dta",1) = ""
^kza("mltab","TAB","Dta",1,1) = 3214
^kza("mltab","TAB","Dta",1,2) = "Name Second"
^kza("mltab","TAB","Dta",1,3) = 'type 5'
^kza("mltab","TAB","Dta",1,4) = 89000
但是我不需要保存第一行,所以如何消除这个节点:
^ kza(&#34; mltab&#34;,&#34; TAB&#34;,&#34; Dta&#34;,1)=&#34;&#34;
答案 0 :(得分:2)
尝试制作所需的num,name,type或pay属性(如果有任何不能为null) Caché定义了^ kza(“mltab”,“TAB”,“Dta”,1)节点,因为如果其他4个字段都为null,则存在^ kza(“mltab”,“TAB”,“Dta”, 1)节点定义行的存在。 换句话说,如果num,name,type或pay都为null并且未定义^ kza(“mltab”,“TAB”,“Dta”,1),则不会定义该行。