ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Duplicate key on access path error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Duplicate key on access path error

    Hi,
    There is one serious error Iam facing with, i.e. Duplicate key on access path.
    Iam writing one RPG program, in which Iam writing a record to a physical file through a logical file. I've defined two logical files over that physical file and using only one in my program.

    Now the problem is, the first logical file cotnains one key E.g. employee id and second logical file contains one key E.g. Employee name. Now iam trying to insert a record using first logical file with data employee id and employee name.

    Now if the employee name is the one in second logical file then this error is coming.If the employee name is something else then no error is coming. But, I've nowhere declared and used the second logical file in my program.

    And also I've not changed the defaults while creating the logical files and the physical files.

  • #2
    Re: Duplicate key on access path error

    Just add the cutomer number to the second logical.
    When you update a physical or logical --- *ALL logicals are updated.
    I can guess that the second logical (the one by name) has a unique keyword in it.

    so.......I would just add customer number after customer name.


    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Duplicate key on access path error

      Or ... If "duplicates" are legal, simply remove the UNIQUE from the objecting logical.

      Comment


      • #4
        Re: Duplicate key on access path error

        I cannot change the physical file DDS. UNIQUE keyword is mandatory as per the requirement. I guess this issue is related to OS. Can u suggest any alternative solution.

        Comment


        • #5
          Re: Duplicate key on access path error

          If u cant change the dds then the only way is to always do a second chain to the logical by name and if found then change the name some how.

          This will work but the solution is wrong!!!!

          the second logical should have the customer number as part of the key.

          jamie
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Duplicate key on access path error

            If you are not allowed multiple entries with the same name (UNIQUE is required), then why would you want your program to write a duplicate?

            I guess the point here is that the 2nd logical acts as a constraint on the PF, even though its not delcared in the program. This is, in fact, how databases work.

            It woudl seem that there is something wrong in the "requirements", since it is possible to have 2 employees with the same name. Adding the employee number as a second key field in 2nd logical, as suggested, would solve the problem.

            Comment

            Working...
            X