I'm chaining a field to a unique keyed PF.
I'm getting a not found indicator so I'm trying to write the record but I receive a duplicate key error. How this can be I do not understand.
A colleague suggested that a field (or fields) within the record might be a key of other LF's over the file and I should clear the record before trying to write a new one.
Problem is; the file has 80 or so fields. How do I clear all these fields easily or is there some way to clear the record entirely in one op?

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

Processing your response...

Discuss This Question: 5 &nbspReplies

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

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

Odd problem - clear will clear all fields.
But you need to determine which logical/physical files declare this file as unique,
the other logicals don't matter for this analysis.
Leaving some fields blank or zero might cause your error if those fields are key fields
for a unique key!
The command DSPDBR will show all the logicals linked to a physical file so you can search for the
file(s) with unique key rules.

I'm using RPG3 and although I know some SQL, I do not know how to add the statement to my program, or if it can be added, so I tried the CLEAR option as suggested but I still get the "Duplicate key on access path" error.
After I wrote the initial post last night, I tried copying the file to my lib, clearing it, then tried to write a new record to it and I received the same error message!
There is another message in the joglog that states "Duplicate record key in member F4101LC." I'm going to assume that this is the unique LF that's causing the problem. So I will try to determine which field it is.
Thanks for your help.

The copy that you made to your library won't have any logicals on it.
But You've got the answer
"Duplicate record key in member F4101LC"
this is a multi-member file.
Members are record containers within the file.
If you do DSPFD you will discover the list of members.
When you do a chain you probably are attempting to get a record in the first member only.
But when you do a write the DBMS is enforcing the UNIQUE across all members.
You want to chain into this file by an access path that has the OVRDBF command set to
*ALL members. I think that will find the record.
But you want to write to this file using a specific member. Perhaps a second access path.
I don't remember ever encountering a UNIQUE constraint placed on a multi-member file.

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

Processing your reply...

Ask a Question

Free Guide: Managing storage for virtual environments

Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!

Share this item with your network:

To follow this tag...

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