ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

record lock.

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

  • record lock.

    hi

    i have a physical file will update by multiple user and approve the record at the same time via screen.

    i need to simulate a situation the record has been locked and enable to approve the record.

    how can i do it?
    if i use alcobj then the screen program will not run.
    i am stressed out thanks plz help

  • #2
    Re: record lock.

    Hi Peacealida:
    When you chain to populate your screen use the no-lock option.
    Code:
    /free
          chain(n) (mykey1 : mykey2) myfile ;
    /end-free
    or in fixed format.......
     c      myklist    chain myfile                   99
     c                 unlock myfile
    When you are ready to update the file you must
    1. re-chain without the nolock option
    2. move the updated fields to output fields
    3. then do the update.

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: record lock.

      GLS400, your fixed format example is missing the (n)

      This works just the same in fixed format as it does in free format. No need to lock it and then subsequently unlock it.

      Comment


      • #4
        Re: record lock.

        Originally posted by GLS400 View Post
        When you are ready to update the file you must
        1. re-chain without the nolock option
        2. move the updated fields to output fields
        3. then do the update.
        There should usually be a step between (1) and (2) that verifies that no intervening changes have happened. If a change is detected, the logic should go through whatever resolution is appropriate, e.g., reject the current update and restart with the recently updated values.
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #5
          Re: record lock.

          thanks for the solution.
          but anyway i can simulate the locking error?

          Comment


          • #6
            Re: record lock.

            Hi

            Try to allocate record using UPDDTA
            LP Zdenko

            Comment


            • #7
              Re: record lock.

              Write yourself a small batch program that reads the record for update (thus locking it) then waits for 10 minutes (use DLYJOB) When you've finished testing your locking code, you can kill the batch job.

              Comment


              • #8
                Re: record lock.

                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


                • #9
                  Re: record lock.

                  Why write a batch program? To lock the record just run the program you are testing from two different 5250 sessions and try to update the same record. Voila - record lock!

                  Comment


                  • #10
                    Re: record lock.

                    Hello Peacealida,
                    An additional info on Record lock.

                    If you want to evaluate the record lock scenario, you could do that in your program logic by checking the value of file status code.
                    In case of RPG,
                    C CHAIN(E) Empfile
                    C IF %ERROR
                    C select
                    C when %status = 01218
                    C 'RecordLocked'DSPLY
                    ....

                    In case of Cobol, you need to check if the value of file status is "9D" or not.

                    Upon validating the file status code, you can take the appropriate action.
                    And, if you also want to identify the JOB which is holding the lock at that moment, you may have to look into the "Error description field" of Program Data structure (i.e. SDS; positions 91 to 170).

                    As far as replicating the record lock scenario, the easy way is to use UPDDTA or executing the same program from another session.
                    Hope that helps.

                    Comment


                    • #11
                      Re: record lock.

                      I've seen UPDDTA mentioned a couple of times in this thread, but I do not believe that will work. (As far as holding a record lock.) UPDDTA will not lock the record while the data is on the screen. It only locks the record for a brief time while the data is being updated.
                      Michael Catalani
                      IS Director, eCommerce & Web Development
                      Acceptance Insurance Corporation
                      www.AcceptanceInsurance.com
                      www.ProvatoSys.com

                      Comment

                      Working...
                      X