DCOUNT in DICT, Which Correlative?

168 views
Skip to first unread message

inavran

unread,
Jul 19, 2011, 10:10:11 AM7/19/11
to jBASE
Hi,

Does anyone know the equivalent correlative or command for what would
be DCOUNT() in DATABASIC, in a DICT.

eg.

1) I would like to count how many commas "," there are in attribute 1
2) I would like to count how many @VMs there are in attribute 3

Im assuming its the same command for both of the above.

I was playing with Corr type A, NV, but that lists a rolling count of
the value markers and explodes them out.

Any suggestions would be helpful.

many thanks

Ian



pat

unread,
Jul 19, 2011, 4:55:40 PM7/19/11
to jBASE
Try :

DICT file comma_count

001 I
002 COUNT(f1,',')
003
004 Commas in Attr1
005 10R

DICT file f1

001 D
002 1
003
004 Attr1
005 10L

DICT file vm_count

001 I
002 COUNT(f3,',')
003
004 VM's in Attr3
005 10R

DICT file f3

001 D
002 1
003
004 Attr3
005 10L

Charlie Noah

unread,
Jul 19, 2011, 5:36:25 PM7/19/11
to jb...@googlegroups.com
002 COUNT(@RECORD<1>, ',')
002 COUNT(@RECORD<3>, @VM)
counts the number of commas and value marks, respectively

002 IF @RECORD<1> # '' THEN COUNT(@RECORD<1>, ',') + '1' ELSE '0'
002 IF @RECORD<3> # '' THEN COUNT(@RECORD<3>, @VM) + '1' ELSE '0'
counts the number of comma and value mark delimited values (even if the values are null), respectively

Charlie Noah

Jim Idle

unread,
Jul 19, 2011, 7:02:20 PM7/19/11
to jb...@googlegroups.com

Actually, woah mule, woah mule!!!

 

1.       The fact that it is awkward to do should be telling you something.

2.       It should be telling you that your data model is completely screwed up.

3.       In the MV model, the separators are AM, VM and SVM.

4.       If you have comma separated values in an attribute mark, then it means you have utterly disregarded the MV data model

5.       You should have multivalues.

6.       You should correlate them if order is important.

7.       Now you find you must count the commas because you are ignoring the data model and have set out down the path to a terribly organized database.

8.       However, don’t feel so bad, as you are merely joining the ranks of just about everyone else.

 

Jim

--
Please read the posting guidelines at: http://groups.google.com/group/jBASE/web/Posting%20Guidelines
 
IMPORTANT: Type T24: at the start of the subject line for questions specific to Globus/T24
 
To post, send email to jB...@googlegroups.com
To unsubscribe, send email to jBASE-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en

Charlie Noah

unread,
Jul 19, 2011, 10:20:10 PM7/19/11
to jb...@googlegroups.com
Hi Jim,

It's been a while!

For the most part you are correct. However, it could be useful to count csv values within an attribute (we're dealing with csv more and more), and it obviously can be useful to know how many multivalues there are. I don't know how many times I've run across definitions that don't take a null attribute into account. Besides, most of us work with systems we've inherited, and which may not have been real well designed in the first place. Many were built by users who found Multivalue based environments so easy to build things in that they considered them developers, even though they were not at all qualified. We still have to work with them, though, and I don't know about you, but I'm getting too old and tired to redesign every system I run across. :-P

Besides, the OP asked for a technical solution to a specific need, not describing the overall scenario, and that's what he got.

It's a shame Jbase didn't incorporate DCOUNT into JQL (perhaps by now it has).

Best,
Charlie

inavran

unread,
Jul 20, 2011, 12:57:34 PM7/20/11
to jBASE
Thanks everyone for your comments.

I did put this to devsup as well and with help from Dan Ell & Dan
Klein, a more elegant solutions was found.

Thanks for both of them as well.

see below.

Dan Ell's First offered this solution using an I descriptor

001 I
002 DCOUNT(@RECORD<1>,’,’)
003
004 Commas in 1
005 8R

001 I
002 DCOUNT(@RECORD<3>,@VM)
003
004 VM in 3
005 8R

This didn't work for me first time (as DCOUNT subroutine doesn't exist
on jBASE 3.x, Dan thought i was running jb4/5)

Dan Klein, then kindly suggested all i needed to do was to create the
DCOUNT sub, and catalog it so it would be available system-wide

001 SUBROUTINE DCOUNT(result, param1, param2)
002 result = DCOUNT(param1, param2)
003 RETURN

This did the trick nicely....

Over to Jim's point.

Im sorry, but with respect, i think you've got completely wrong end of
the stick.

If i was storing information for db purposes it would be a terrible
model, the fact is, i was storing it as a quick dirty report i needed
(that i was too lazy to write another program for, when i just wanted
a quick ref count on how many MVs i had from each key. (ie the
majority would be a count of 1 and a small few would be > 1), i would
simply then select the keys > 1 and see what sort of data set i was
dealing with.

I put the commas count eg in as literally an example (be it a very bad
example in hindsight) - nothing else.

I would never store multiple values separated by commas in a data
model. (even if i did, i wouldn't be silly to mention it on this a
board)...

Thanks for your reply though, a always enjoy reading your posts :)

Charlie, i found an excellent 4 page pdf (scrapped off the spectrum
website years ago), which describes in detail all the DICTs & ACCESS
commands (similar to JQL). It lists all TCL commands and uses of
correlatives (for A types not I)

If anyone would like a copy of it, let me know and i can put it on a
public dropbox link.

Ian

On Jul 20, 3:20 am, Charlie Noah <cwn...@comcast.net> wrote:
> Hi Jim,
> It's been a while!
> For the most part you are correct. However, it could be useful to count csv values within an attribute (we're dealing with csv more and more), and it obviously can be useful to know how many multivalues there are. I don't know how many times I've run across definitions that don't take a null attribute into account. Besides, most of us work with systems we've inherited, and which may not have been real well designed in the first place. Many were built by users who found Multivalue based environments so easy to build things in that they considered them developers, even though they were not at all qualified. We still have to work with them, though, and I don't know about you, but I'm getting too old and tired to redesign every system I run across.:-P
> Besides, the OP asked for a technical solution to a specific need, not describing the overall scenario, and that's what he got.
> It's a shame Jbase didn't incorporate DCOUNT into JQL (perhaps by now it has).
> Best,
> Charlie
> On 07-19-2011 6:02 PM, Jim Idle wrote:
>
> Actually, woah mule, woah mule!!!
>
>
>
>  
>
>
>
> 1.      The fact that it is awkward to do should be telling you something.
>
>
>
> 2.      It should be telling you that your data model is completely screwed up.
>
>
>
> 3.      In the MV model, the separators are AM, VM and SVM.
>
>
>
> 4.      If you have comma separated values in an attribute mark, then it means you have utterly disregarded the MV data model
>
>
>
> 5.      You should have multivalues.
>
>
>
> 6.      You should correlate them if order is important.
>
>
>
> 7.      Now you find you must count the commas because you are ignoring the data model and have set out down the path to a terribly organized database.
>
>
>
> 8.      However, don’t feel so...
>
> read more »

Charlie Noah

unread,
Jul 20, 2011, 2:32:55 PM7/20/11
to jb...@googlegroups.com
Hi Ian,

I'd love to get a copy of that PDF. Let us know where you end up putting it so I can grab a copy.

Have you done a performance test to determine if the subroutine is faster or slower than the I-descriptor with COUNT? I'd be very interested in your results. I'm glad to know I'm not the only one still running 3.x.

Thanks,
Charlie

Jim Idle

unread,
Jul 20, 2011, 2:56:44 PM7/20/11
to jb...@googlegroups.com
> -----Original Message-----
> From: jb...@googlegroups.com [mailto:jb...@googlegroups.com] On Behalf
> Of inavran
> Sent: Wednesday, July 20, 2011 9:58 AM
> To

> This did the trick nicely....
>
> Over to Jim's point.
>
> Im sorry, but with respect, i think you've got completely wrong end of
> the stick.

No I haven't.

Jim

inavran

unread,
Jul 21, 2011, 4:34:26 AM7/21/11
to jBASE
Hi Charlie,

I haven't done a performance test, but I've been informed by Dan Klein
(who has helped me alot in the past, and i trust) that calling a
global subroutine within an I-Type dictionary will perform much better
than using a A-type; 008: CALL mysub or 008:B;mysub (which ive found
very slow in the past, and therefore wont use), i sure Jim will say if
im right or wrong?

Those PDFs i found on the web has been very informative reading. Its
not specific to jBASE, but alot of the commands work, and it filled in
alot of gaps to do with A-type DICTs

Here's a link to a public goggle docs share : http://tinyurl.com/3vly68j

I dont think i will be putting the time in to test it out, as we will
be migrating to jb 5.2.x in the coming months (ive been saying that
for 6 months already though!). jb3 has served us well, but its time to
move on.

Do you have any plans to migrate soon?

Ian

Mark Hogden

unread,
Jul 21, 2011, 9:38:07 AM7/21/11
to jb...@googlegroups.com
If you are planning on migrating to 5.2.X, you would be well served by
converting all your correlatives to I-TYPES.

-----Original Message-----
From: jb...@googlegroups.com [mailto:jb...@googlegroups.com] On Behalf Of
inavran
Sent: Thursday, July 21, 2011 1:34 AM
To: jBASE
Subject: Re: DCOUNT in DICT, Which Correlative?

Hi Charlie,

Ian

--

Charlie Noah

unread,
Jul 22, 2011, 9:11:17 AM7/22/11
to jb...@googlegroups.com
Hi Ian,

I was thinking more of the subroutine call versus the 002: COUNT(... approach. I've always found subroutine calls slower, at least in 3.x.x. I've never had good luck with the A type 008 CALL.

I'm not looking to upgrade anytime soon. I suppose I'll have to eventually, but I'm putting it off as long as I can, and when I do, it will likely be to 4.x.

Charlie

Charlie Noah

unread,
Jul 22, 2011, 9:11:57 AM7/22/11
to jb...@googlegroups.com
Why?

Charlie Noah

Charlie Noah

unread,
Jul 22, 2011, 9:23:02 AM7/22/11
to jb...@googlegroups.com
Hi Ian,

The tinyurl link didn't find any documents. I searched multivalue and came up with "mv SELECTs, DICTs", parts 1 thru 5. Is this what you're referring to?

Thanks,
Charlie

On 07-21-2011 3:34 AM, inavran wrote:

Gmail

unread,
Jul 22, 2011, 9:03:42 PM7/22/11
to jb...@googlegroups.com
Hi Charlie, 

yeah those are the ones, sorry the tinyurl didn't work.

Enjoy.

I'm gonna be offline for the next week or so, my wifes just gone into labour!

Cheers!

Ian 
--
Reply all
Reply to author
Forward
0 new messages