[英]How do associations, @NS and @NV work in UniData Dictionaries?
Does anyone have a quick example of how Associations, @NS
and @NV
work in UniData? 有没有人有一个简单的例子说明UniData,
@NS
和@NV
如何在UniData中工作?
I'm trying to work out associations in dictionary items but cannot get them to do anything. 我正在尝试找出字典项中的关联,但无法使它们执行任何操作。
For example, in a record 例如,在一条记录中
<1,1> = A
<1,2> = B
<2,1> = Apple
<2,2> = Banana
I created 3 dictionary items. 我创建了3个字典项。 LETTER and FRUIT, COMBO as follows
字母和水果,组合如下
LETTER: 信:
<1> = D
<2> = 1
<3> =
<3> = Letter
<4> = 6L
<5> = M
<6> = COMBO
FRUIT: 水果:
<1> = D
<2> = 1
<3> =
<3> = Letter
<4> = 6L
<5> = M
<6> = COMBO
COMBO: 组合:
<1> = PH
<2> = LETTER FRUIT
Doing a LIST LETTER FRUIT
or LIST COMBO
has no difference to when LETTER and FRUIT do not have an association declared in 6. 进行
LIST LETTER FRUIT
或LIST COMBO
与6中未声明LETTER和FRUIT的关联没有区别。
At this point I thought it might group multivalues together when SELECTing so I created another record as such: 在这一点上,我认为选择时可能会将多值分组在一起,所以我这样创建了另一条记录:
<1,1> = A
<1,2> = B
<2,1> = Banana
<2,2> = Apple
Doing SELECT MyFile WITH LETTER = “A” and FRUIT = “Apple”
selects both records, so that cannot be it either. SELECT MyFile WITH LETTER = “A” and FRUIT = “Apple”
执行SELECT MyFile WITH LETTER = “A” and FRUIT = “Apple”
选择两个记录,因此也不能选择两个记录。
I then tried changing LETTER to be: 然后,我尝试将LETTER更改为:
<1> = I
<2> = EXTRACT(@RECORD,1,@NV,1);EXTRACT(FRUIT,1,@NV,1);@1:" (":@2:")" : @NS
<3> =
<3> = Letter
<4> = 6L
<5> = M
<6> = COMBO
Hoping it that a LIST MyFile LETTER
would bring back all the different letters with their associated fruit in parentheses. 希望
LIST MyFile LETTER
会带回所有不同的字母,并在括号中加上相关的果实。 That didn't work either as now LETTER only ever displayed the first Multivalue instead of all of them. 这也不起作用,因为现在LETTER仅显示第一个Multivalue而不是全部。 For Eg:
例如:
LIST MyFile LETTER 14:05:22 26 FEB 2010 1
MyFile.... LETTER..............
RECORD2 A (Banana)1
RECORD A (Apple)1
2 records listed
The manuals don't go any further than saying the word “association”. 这些手册只不过说了“协会”一词而已。 Is anyone able to clarify this for me?
有人能为我澄清这一点吗?
Many times NV and NS only work when using BY-EXP in your LIST or SELECT statements. 很多时候,NV和NS仅在LIST或SELECT语句中使用BY-EXP时才起作用。 You need to use modifiers that specifically look at MultiValue and SubValues.
您需要使用专门查看MultiValue和SubValues的修饰符。
WHEN is one, and BY-EXP is another. WHEN是一个,而BY-EXP是另一个。 There are other, but not sure what they are off the top of my head.
还有其他,但不确定是什么让我烦恼。 I primarly use BY-EXP and BY-EXP-DSND.
我主要使用BY-EXP和BY-EXP-DSND。
LIST MyFile BY-EXP LETTER = "A" BY-EXP FRUIT ="Apple" LETTER FRUIT LETTER.COMBO
To bring back all the combinations, you use need to do the following: 要恢复所有组合,您需要执行以下操作:
LIST MyFile BY-EXP LETTER LETTER FRUIT LETTER.COMBO
Change the following virtual field from 'LETTER' to say 'LETTER.COMBO' or something along those lines: 将以下虚拟字段从“ LETTER”更改为“ LETTER.COMBO”或类似的内容:
<1> = I
<2> = EXTRACT(@RECORD,1,@NV,1);EXTRACT(FRUIT,1,@NV,1);@1:" (":@2:")" : @NS
<3> =
<3> = Letter
<4> = 6L
<5> = M
<6> = COMBO
Hope that helps. 希望能有所帮助。
-Nathan -内森
To answer part of my own question: 要回答我自己的问题的一部分:
Only 'WHEN' is affected by the association, not with. 只有“何时”受关联的影响,而不受关联的影响。 If you turn on UDT.OPTIONS 94 and do
如果您打开UDT.OPTIONS 94并执行
LIST MyFile WHEN LETTER = "A" AND FRUIT="Apple" COMBO
when using my D-Type definition of LETTER, I get 当我使用LETTER的D-Type定义时,我得到
LIST MyFile WHEN LETTER = "A" AND FRUIT="Apple" LETTER FRUIT 16:06:42 26 FEB 2010 1
MyFile.... LETTER.............. FRUIT...............
RECORD A Apple
1 record listed
Which is what one would expect. 这是人们所期望的。
To use the WHEN clause you need to be in ECLTYPE U, not P. IT would be helpful if this was clearer, but oh well... 要使用WHEN子句,您需要使用的是ECLTYPE U,而不是P。如果更清楚的话,它会有所帮助,但是,好吧...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.