dbTalk Databases Forums  

Running Count on Multivalue Attribute

comp.databases.pick comp.databases.pick


Discuss Running Count on Multivalue Attribute in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
alfmars
 
Posts: n/a

Default Running Count on Multivalue Attribute - 12-28-2005 , 03:54 AM






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.

I've tried creating a dictionary item using the @NV variable as follows
: 0001: I
: 0002: @NV
: 0003:
: 0004:
: 0005: 2R
: 0006: MV
: 0007: assORDERS
but nothing is returned in the count attribute. Am I missing something?
On the wrong track completely? Any help or advice would be much
appreciated.

Cheers
Alex


Reply With Quote
  #2  
Old   
mattydp@yahoo.com
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 05:26 AM






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


Reply With Quote
  #3  
Old   
Dave Weaver
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 11:15 AM



This also works:
0008 F3;C1;S

But, note that either way reports "1" if the attribute is null.

Dave Weaver, Weaver Consulting


Reply With Quote
  #4  
Old   
dawn
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 12:13 PM



alfmars wrote:
Quote:
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



Reply With Quote
  #5  
Old   
murthi
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 12:18 PM



You can use A;IF 3='' THEN '' ELSE NV

assuming Unidata has a-corrs with if-then-else

Chandru

"Dave Weaver" <weaver22 (AT) pacbell (DOT) net> wrote

Quote:
This also works:
0008 F3;C1;S

But, note that either way reports "1" if the attribute is null.

Dave Weaver, Weaver Consulting




Reply With Quote
  #6  
Old   
Dave Weaver
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 12:53 PM



On D3, Murthi's solution works EXCEPT if the multivalue is "0", the NV
value is null.

I think Dawn is right, the original author (Alex) needs to better
define his requirements and reasons.

Personally, if the requirement was critical for the application, I
would think a CALL to a Basic subroutine would be the better solution
-- that way you have complete control over the outcome rather than
depending on "A" or "F" correlatives and the "NV" function.

Additionally, note that Alex is looking for a Unidata solution. Someone
else will be better able to address that solution, especially for the
CALL method.

Dave Weaver, Weaver Consulting


Reply With Quote
  #7  
Old   
alfmars
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 01:47 PM



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.

Thanks for your help so far

Cheers
Alex

dawn wrote:
Quote:
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


Reply With Quote
  #8  
Old   
dawn
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-29-2005 , 02:54 PM




alfmars wrote:
Quote:
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.
OK, then I really wish I could recall what I did as it worked handily.
My advice is to put this question to u2-users (if you are not on that
list, you can sign up through process described at u2ug.org). [My real
advice is to avoid UniData ODBC if you can and use UOJ instead of jdbc.
There are some examples on pickwiki IIRC].

--dawn



Reply With Quote
  #9  
Old   
Bill H
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 12-31-2005 , 07:27 PM



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

Quote:
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.



Reply With Quote
  #10  
Old   
alfmars
 
Posts: n/a

Default Re: Running Count on Multivalue Attribute - 01-01-2006 , 03:33 PM



Thanks Bill, exactly what I needed!

Thanks for the resource links Dawn, I'm sure I'll be looking for more
help in the future.

Thanks everyone for for your help and input. This group has been an
enormous help for me in learning how to work with Unidata (coming from
a non-multivalue background).

Thanks again
Alex


Bill H wrote:
Quote:
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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.