One thing to realize - the _RLocate function - and all those _R* functions - are the same as some kind of RPG function - you gain nothing by their use - so just use normal RPG - you are already in an RPG program.

No matter what, the rows must be counted - SQL does it very well - but you can do a SETLL on the key, then READE until %eof, incrementing a counter at each read - easy - SQL will do almost the same thing, but probably faster.

If the condition is not one of the keys, SQL is the better bet - it will take care of the sort that you need.

Run away from those _R* C/C++ functions unless you REALLY know why you want to use them. There is one situation I know of that calls for their use instead of native RPG, but I will keep quiet about that for now.

HTH
Vern

On 3/22/2012 4:31 PM, Vinay Gavankar wrote:
Thanks. There could be potentially hundreds of thousands of records.

On Thu, Mar 22, 2012 at 4:39 PM, Vern Hamberg<vhamberg@xxxxxxxxxxx> wrote:

Hi Vinay

Then an embedded SQL statement - as Alan suggested - is very easy - put
your condition into a WHERE clause -

SELECT COUNT(*) FROM YOURLIB/YOURFILE WHERE KEYFIELD = KEYVALUE

If Keyfield is alpha, remember to use apostrophes around KEYVALUE.

You have to work with that, to get COUNT(*) into an RPG variable - the
manuals give you all that if you need the information.

HTH
Vern

On 3/22/2012 10:56 AM, Vinay Gavankar wrote:
It is in an RPG program.

On Thu, Mar 22, 2012 at 10:31 AM, Stone, Joel<Joel.Stone@xxxxxxxxxx>
wrote:
Please explain what you are trying to do.

Are you trying to retrieve this count into a CL variable?

Then use this command:

LOOKUPSQL LOOKUPEXP() TABLE(cust) +
WHERE('custkey = ''123''') RETURNVAR(&custCount)

Uses LOOKUPR



http://www.mcpressonline.com/programming/sql/using-dynamic-sql-in-cl-part-2retrieving-a-data-value.html



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:
midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vinay Gavankar
Sent: Wednesday, March 21, 2012 6:26 PM
To: Midrange Systems Technical Discussion
Subject: Documentation about QC2LE

Hi,

Where can I find any documentation about what procedures are available
in
QC2LE directory, and maybe how to use them?

I came across a program, which was using prototype called _RLocate to
get
the RRN of a record based on a key from a keyed logical file.

I wanted to get the total number of records in that file which have Key
equal to a particular value.

Any information would be helpful.

Thanks
Vinay
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


________________________________________________________________________
This inbound email has been scanned for all viruses by the MessageLabs
SkyScan
service.
________________________________________________________________________

______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs
Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].