![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi I'm pretty new to Unidata and multi-value databases, and need some help with counting values in a multivalue attribute. I need to create a dictionary item that lists a running count of an associated multi-value attribute, so if I queried the file using something like LIST ORDERS ORDER_NUM COUNT_ORDER_NUM I'd get an output like:- A123 1 A234 2 A456 3 etc where ORDER_NUM and COUNT_ORDER_NUM are associated multivalue attributes. |
#5
| |||
| |||
|
|
This also works: 0008 F3;C1;S But, note that either way reports "1" if the attribute is null. Dave Weaver, Weaver Consulting |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
alfmars wrote: Hi I'm pretty new to Unidata and multi-value databases, and need some help with counting values in a multivalue attribute. I need to create a dictionary item that lists a running count of an associated multi-value attribute, so if I queried the file using something like LIST ORDERS ORDER_NUM COUNT_ORDER_NUM I'd get an output like:- A123 1 A234 2 A456 3 etc where ORDER_NUM and COUNT_ORDER_NUM are associated multivalue attributes. If I am understanding, I have seen this done when doing ODBC against UniData data. Because the view splits out the association into a logical table you lose the ordering. Using UniData SQL, you can use another means to get this number (I'm forgetting that now but it is well documented IIRC), but you cannot create a UniData view with this number (or at least you could not with UniData 6.1). Is that the purpose? If so, I have done that and I'm sorry I don't recall how. I recall adding an I-descriptor that counted, so it was an MV field that was 1, 2, 3, 4, 5, ..., n and added the association to this I-desc. If you are not doing this for ODBC purposes, then perhaps you could give us more of a clue of what you would be using it for. There might be other ways to address the end goal. --dawn |
#8
| |||
| |||
|
|
Thanks for your replys and sorry for not providing enough info at the start. Dawn, you're spot on with what I'm trying to achieve. We're using Unidata 6 and I'm looking to create flattened SQL views (using the unnest funtionality) so that the data can be accessed using odbc, jdbc or similar. The purpose of the count is, as you mentioned, to provide a way of recording the order of the multivalues when they are flattened out into separate logical tables. The documentation from IBM suggests that the @NV or @VALUE.COUNT variables together with an association should provide this functionality, but that's not working for me and unfortunately there weren't any examples in the docs. |
#9
| |||
| |||
|
|
Not sure if this is what you're after but say you wanted to know how many multivalues are in a particular attribute (number 3 in this example) then this F correlative works. 0001: A 0002: 0 0003: MV Count 0004: 0005: 0006: 0007: 0008: F3;P;=;S 0009: R 0010: 8 HTH Matt alfmars wrote: Hi I'm pretty new to Unidata and multi-value databases, and need some help with counting values in a multivalue attribute. I need to create a dictionary item that lists a running count of an associated multi-value attribute, so if I queried the file using something like LIST ORDERS ORDER_NUM COUNT_ORDER_NUM I'd get an output like:- A123 1 A234 2 A456 3 etc where ORDER_NUM and COUNT_ORDER_NUM are associated multivalue attributes. |
#10
| |||
| |||
|
|
UniData gentlemen! :-) If you want to count "values" in an attribute try: 001 V 002 DCOUNT(EXTRACT(@RECORD, n, 0, 0), @VM) 003 004 VC 005 2R 006 S If you want a "running total" of values in an attribute try: 001: V 002: EXTRACT(@RECORD, 7, 0, 0) ; @NV 003: 004: NV 005: 2R 006: M Hope this helps. Bill mattydp (AT) yahoo (DOT) com> wrote in message news:1135855574.042818.238700 (AT) o13g2000cwo (DOT) googlegroups.com... Not sure if this is what you're after but say you wanted to know how many multivalues are in a particular attribute (number 3 in this example) then this F correlative works. 0001: A 0002: 0 0003: MV Count 0004: 0005: 0006: 0007: 0008: F3;P;=;S 0009: R 0010: 8 HTH Matt alfmars wrote: Hi I'm pretty new to Unidata and multi-value databases, and need some help with counting values in a multivalue attribute. I need to create a dictionary item that lists a running count of an associated multi-value attribute, so if I queried the file using something like LIST ORDERS ORDER_NUM COUNT_ORDER_NUM I'd get an output like:- A123 1 A234 2 A456 3 etc where ORDER_NUM and COUNT_ORDER_NUM are associated multivalue attributes. |
![]() |
| Thread Tools | |
| Display Modes | |
| |