is there a method of doing Count in JDE ?

tatscub

tatscub

Member
Hello Everyone I have come across an interesting issue I haven’t had to tackle in JDE before and I'm hoping someone can give me a kick in the right direction

what i would ideally like to do is something like a SQL count statement if its possible to read back the number of rows in a table that have one field with the same value i.e select into variable foo the number of rows that have field x = bar where the key is bla bla bla . and then use that in my code to say if foo is >1 then go off and do stuff . I would be very grateful for any help and advice any one can give me

Thanks
Charlie
 
Hi,

there are aggregate functions in the JDB API which can be used in a C-BSFN. Search the source files for JDB_AGGRGFUNC_COUNT and you will find some examples... at least I hope so, I don't know if this has been around in 7333.

On the other hand, if you're not really interested in the exact number of records but just want to know if it's more than one, why don't you just use an ER Select/FetchNext loop? If you don't have too many "duplicates", then this should be good enough to distinguish many from one... If you're "many" is a high number though, you may want to talk to your database admins first regarding the potential impact.

Best Regards
 
thank you for your help i resolved it in the end using a select -> while -> fetch next loop with a variable inside that I incremented by one each time the loop went round . not as neet as a nice count statement but hey im great beliver in if its working dont knock it LOL

Thank you again for all your help

Charlie
 
The best way is to create a BSFN and you the API JDB_SelectKeyedGetCount. This is like doing a count in SQL
Thanks
 
Back
Top