Working with multiple fields

770 pts.
Tags:
AS/400
RPG/400
We have 8 fields in a file.In those fields sixth is the only Non Key Field(Other 7 are keyed fields).Now I want to pull the unique records according to the Sixth field using RPG.

Software/Hardware used:
AS400

Answer Wiki

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

Using OPNQRYF command u can achieve your requirement.

In that command after query selection there is a field for key field in that field select sixth field as a key field…

Try this..If there is any other way kindly update…..

Discuss This Question: 4  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
    So you want to get the file in order on the 6th field or access a recird based on the value of the 6th field optons are: - build a logical file keyed on the 6th field - build an SQL index based on the 6th field - use imbedded SQL - if it needs it, the system will build a temporary index - use OVRDBF and OPNQrY to deliver the file keyed on the 6th fie Surely other options exist Phil
    50,505 pointsBadges:
    report
  • ankit2002
    Tks Phil ...I will appreciate if you can provide some reference code which can help me better in understanding this scenario.
    770 pointsBadges:
    report
  • philpl1jb
    What!!! Not time for code. Time to identify which one of the 4 options fits your needs. You want to do discreate accesses (like Chains) It would be good to either - build logical and use Chain - create an index and use embedded SQL select Phil
    50,505 pointsBadges:
    report
  • TomLiotta
    I want to pull the unique records according to the Sixth field... If all of the other fields are key fields, the implication is that this field may be duplicated many times. It's possible that there could be only a few 'unique' values out of every 1000 records. It's possible that there could only be a few 'unique' values in the entire file. It can be done in RPG. But some methods actually require RPG plus some CL, or RPG plus some SQL, or RPG plus some DDS. Are you trying to find a way to do it only in RPG? If so, are you using ILE RPG? In RPG, you would do it by reading each record and storing the field value in an array (or some other container). Every time you found a value that was already in the array (or container), you'd go to the next record. You would only store values that hadn't been stored before. When you reached the end of the file, the array would contain each unique value in a different element. But if you used other tools such as SQL, you could simply SELECT DISTINCT values of that field and FETCH the distinct values. In any case, it's not clear precisely what you need to do. Are you trying to learn RPG? Or are you trying to solve a business problem? The methods we might suggest will probably be very different depending on exactly what your goal is. Tom
    125,585 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