345 pts.
 AS/400 COBOL
one physical file have 6 key fields,now i want to retrive the 10th record

based on one key field,how to retrive in cobol/400 with without using logical file

ex:- emp pf have 6 key fields,and emp have records,now i want to retrive particular record in emp(10 th record only),in my cobol pgm some times use 6 key fields and some time i want use only one key field with out using logical files

pls give replay with small example



Software/Hardware used:
software
ASKED: October 5, 2011  10:07 AM
UPDATED: March 31, 2012  12:36 AM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

If you only want to use a physical file (a ‘table’) and you program cannot know ahead of time which fields will be used as selection (key) fields out of six possible ones, there are three general possibilities.

  1. Use dynamic SQL. Specify a WHERE clause that provides whatever selection criteria is supplied.
  2. Read each each record and use IF-tests to see when records match.
  3. Use OPNQRYF to create a dynamic access path each time.

In each case, count the records until you reach 10. (With SQL you might use relative positioning.)

I suppose it’s also possible to use the C library functions such as _Rlocate() — Position a Record to retrieve specific records, but it’s not clear how you would use those when no appropriate access path existed (without creating one which seems to violate a “no LFs” rule.)

Tom

 110,135 pts.