AS/400: concept of Unique key

160 pts.
Tags:
AS/400
AS/400 Duplicate Files
Physical File
Unique key
Hi,

I have a PF wiht 3 fields.

I  created LF based on this PF, with first 2 fields as Key fields and specify file level key work UNIQUE in that LF.

What will happend if I add the duplicate records in PF object...?

 

Answer Wiki

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

I believe PF does not allow you to add duplicate entries. If the PF already contains duplicate entires, then the LF created based on PF might not fetch the data, you should see an error “FILE in LIB not valid for operation.”

—————
That’s right, you cannot add records to the PF if they violate any unique constraint on the physical or logicals. You cannot create the LF if the PF contains any records that would violate the unique constraint in it’s definition.
Phil

——————–

Hi…

I think if the PF already contains duplicate records then on quering on LF (with unique) it will show only the first record..Please correct me if wrong..

SB

Discuss This Question: 2  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
  • Cwc
    SB, in answer to your last question: If the physical file allows and already contains records with duplicate keys, and you want to create a logical over it which doesn't allow those duplicates, the database management system will not let you create that logical, since it will not compile successfully. So, the system prevents that situation from happening in the first place.
    4,290 pointsBadges:
    report
  • philpl1jb
    As CWC said, if the logical file has a UNIQUE file level declaration, the logical file's composite key must be unique. It will not compile if the composite key is not unique and if it's compiled it will not allow the addition or change of records that will violate this rule. It's the LF's composite not the PF's composite key list and not individual fields but the composite that must be unique. 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