AS/400 Scenario

770 pts.
Tags:
AS/400
AS/400 Records
RRN
Q. I have a file with millions of records and I want to read the last record from that file.But the conditions are as follows(assume): 1. The file do not have any key field. 2. The file do not give any RRN Number(Assume). 3. We are not allow to use the loop till EOF as we have millions of records. So taking care of the above conditions how to read the last record from the file.

Software/Hardware used:
AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

Thank you for visiting ITKE.

We are happy to help you with solving specific IT questions, but need as
much information as possible to do so. Let us know about the problem you
are trying to solve, how you are approaching it and what work you’ve
done so far, and we can help guide you in the right direction.

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    The setup seems almost academic. To require the reading of just the last record out of millions seems to indicate a database structure that needs to be fixed. What language are you allowed to use? You might use OVRDBF POSITION(*END) before calling your program, and then use a read-previous operation in your chosen language. There are also language-specific alternatives. Tom
    125,585 pointsBadges:
    report
  • BigKat
    no almost about it Tom, that question has to be pure homework
    8,060 pointsBadges:
    report
  • TomLiotta
    @BigKat: I'd like to be sure. A number of real-life encounters in the past couple years have made me more cautious -- admins(!) who don't know how to look at messages, don't know where joblogs are nor how to generate them, you name it. So, I figure it's okay to refer to a "read-previous operation" without saying how to do it. The worst that would happen is a search in a reference guide, and that's probably the best thing to learn anyway. And if it becomes a dialog, enough info should come out to be sure. Tom
    125,585 pointsBadges:
    report
  • ankit2002
    Guys I tried this it was giving the right result. *HIVAL SETGT Filename READP Filename Name DSPLY
    770 pointsBadges:
    report
  • Splat
    You could use the INFDS to retrieve the number of records in the file then retrieve the last record by RRN. Please note, this wouldn't work if your file is defined as REUSEDLT(*YES).
    7,055 pointsBadges:
    report
  • TomLiotta
    ...this wouldn’t work if your file is defined as REUSEDLT(*YES). Of course, no other method would work either. That is, without something to key on, e.g., a timestamp, the only way to find a 'last record' is to use the highest available RRN. The INFDS works just as well for that as anything else. By 'key on', I simply mean a value that can be recognized. It doesn't need to be an index key. But the restrictions say that records cannot be read in order to test their values. The only thing available that I can think of is highest RRN. If REUSEDLT(*YES) is in effect, it still goes straight back to thinking that it's a database that is in trouble and needs to be rearchitected. Tom
    125,585 pointsBadges:
    report
  • Yorkshireman
    So if its homework - and that seems likely, as any IBM i system with a file of that nature wouldn't have a file like that, then we contribute to the frovolity by answering. But it is intriguing. Probably aimed at PC geekdom, where they get themselves into such troubles. you could postulate access by disk address if you're geeky - read the FAT, go to a location - that would be geeky. I could suggest an obvious DB2 solution to such a question, but I'll keep quiet. Oh wait - 2 solutions.
    5,580 pointsBadges:
    report
  • HMSSL2K
    Only way to learn something new is to try yourself. Internet is a great option these days for answers for home work questions.
    3,175 pointsBadges:
    report
  • Kellyd
    SQL? select * from tablename where idColumn in (select maidcolumn ) from table ) select * from tablename where idColumn in (select max ( idcolumn ) from table )
    100 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following