AS/400: Unique records in file

310 pts.
Tags:
AS/400 administration
Logical Files
PF/LF
Physical File
hi all, i have a problem , suppose i have a physical file which has multiple occurrences of fld1 , now i need to access that in distinct (one data single time) order. so i created a logical file with UNIQUE keyword . but when i make query on this LF then msg comes that no member found. and a dump also occurs that duplicate key not allowed.is thai method is correct to find unique data.

Answer Wiki

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

Hi,

You can’t create an LF with unique when the data isn’t unique. What are you using to access the data? RPG, SQL?

One option is to create a new physical with unique and use CPYF with ERRLVL(*NOMAX)

Regards,

Martin Gilbert.

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
    A logical with UNIQUE keyword will prevent adding records that violate the rule. It will error when compiled if the file contains duplicte key values. The method to see one occurance of each varies with the access method. In QUERY/400 you could use report summary functions on fld1 and other fields that you want to report. In RPG you could use the Key - something like this *loval SETTLL myfile Read myfile dow not %eof(myfile) process your record FLd1 SETGT myfile Read myfile enddo The SETGT will position you at the first record past the key value. Phil
    50,505 pointsBadges:
    report
  • Gilly400
    Hi, Or if you're using SQL you could use a SELECT DISTINCT. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • philpl1jb
    Select distinct works great provide that all the fields retrivied are the same for a specific value of FLD1. It retrieves distinctly different rows.
    50,505 pointsBadges:
    report
  • Ambrish 82
    thanks , it's really useful.
    310 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