Reading all AS/400 records

895 pts.
Tags:
AS/400
AS/400 Records
DB2/400
i want to read all the records in a file.. and there are no locks on the file during this process.. how will i read the records in fastest possible manner in AS400

Software/Hardware used:
AS400

Answer Wiki

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

define the file as Input Primary and let the OS handle the File I/O, instead of doing READ or CHAIN.

fFileName IPE Disk

c field_1 ifeq field_2
c —— do something ——
c endif

in this manner, the file is read by RRN and the program handles all of the file I/O and automagically sets on last record indicator.

-sarge

Discuss This Question: 11  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
  • philpl1jb
    Drop the K on the F spec--read them from the physical file in rrn sequence, might help. Large files,SQL might be faster. Perhaps if you gave us more info we could provide better answser. Phil
    51,355 pointsBadges:
    report
  • TomLiotta
    It definitely depends on the structure of the file, the size of the file and the reason for reading. Some files can't be read effectively with RPG native I/O at all, e.g., tables with various LOB columns. It's possible to read such files, but it's hardly an efficient choice. Usually, there are two reasons for wanting to read the records in fastest possible manner. Either the file is small but needs to be read many times, e.g., some kind of lookup table, or it is a very large file that may take a long time to process. (Assuming some recent release of the OS, at least V5R3...) Although SQL will generally outperform RPG native I/O in any sequential processing, larger files tend to put SQL even farther ahead. However, the type of processing that might be done for records that are read can make significant differences. Describe the files for us, and give some indication of what will happen to each record. How old are the files? How are they indexed? Are they DDS files or SQL tables? Will all records be processed the same? Do some records need to be linked to records in other files, while different records will be linked to different files? Are the multiple different calculations for different records? Will there be CALLs into other programs? You haven't even told us what languages you might use. Often, the overall fastest "reading" of a file is done by FTP, so "Use FTP" should be the answer to your question. But it's not likely that helps you much. Unfortunately, you haven't given us much to go on. Until you tell us something about the files and the processes, there is no good answer. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Nutangujar You've asked us a question. We've been polite enough to respond, give you some ideas and ask for further infomation. You owe us a response. Phil
    51,355 pointsBadges:
    report
  • Nutangujar
    Thanks a ton guys.. I was away (from the AS400 world) for a while very sorry for that... actually this was the question i was asked in an interview, and i thought chaining a record with no lock would make the file read faster... essentially the question was to read a file start to end, every record in the file such a way that the processing is done faster..
    895 pointsBadges:
    report
  • TomLiotta
    Then a multiple-row FETCH with blocks sized up to the maximum that SQL can handle (without going over the 32k rows per FETCH limit) is probably the best you can do. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Great that you are getting interviews, there seem to be few of those around. Interview questions are notoriously bad .. this could have been a ten year old question,or the answer they expected was what one of their programers worked out experiemently or they could have left out critical information. How to handle this poor question? "I'm sure you have some very specific solution in mind but I don't have an answer, It feels like your question lacks some critical information that would help frame the solution. Given the flexibility of DB2 and the continued preformance improvements of this system, I'm surprised that there is one fastest method that applies to all cases. Even though I don't know the answser I'm sure that I could develop a solution to your problem. I've had to solve many proformance issues, in solving them I've: - researched the specific case - conducted tests to confirm that I had reliable solution. I suspect that your solution took equal amounts of research and testing." The other tact might be to turn the question around -- not how to read all the records but Why read all the records? What are the business reasons for doing this? Could a summary SQL solve the problem faster? Could a logical file or open query file reduce the number of accesses necessary? As a developer, analyst, designer, isn't it more important that the business reasons for doing a process be explored before getting committed to a specific method? Good luck. Phil
    51,355 pointsBadges:
    report
  • Nutangujar
    Many thanks Phil. I can use those tacts to all those poor questions....I have seen many other wierd interview questions... people try to compare apples with oranges.. this solution applies to all of them .. many thanks....
    895 pointsBadges:
    report
  • Nutangujar
    Thanks Tom!
    895 pointsBadges:
    report
  • slateken
    At first, I agreed that it's a poor question. Then after reading Phil's and Tom's answers, I realized that it is a great interview question. Imagine how your skills are brought to light by your responses to his/her purposely vague or misleading question. Good stuff.
    230 pointsBadges:
    report
  • PSMurray
    All - Excellent interview question - vague. Trust me, I'm over 30 and I've seen many vague interview questions. I've been into programming since the IBM 1620 and went into Consulting in 1985. The questions are vague on purpose. They are trying to understand your expertise AND your ability to communicate. Especially, if the interviewee is a non-technical person. Enjoy, MIS
    530 pointsBadges:
    report
  • philpl1jb
    I'm not entirely sure that it was intended to be vague or that our answer would put us on the path to another level of interview. In my experience, there are lists of questions used by the initial screeners, often phone screening. The people doing this interview are given an answer and told to pass on those who answer X of 10. So the screener is looking for a specific answer and we are boring them and failing to answer their question. Or worse yet, arguing with them. Phil
    51,355 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