ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

I/O error while chaining due to rec lock

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

  • I/O error while chaining due to rec lock

    I have a free format rpg, in which I chain a file and then if record found and necessary conditions are met, it is updated. My main input file has 400,000+ recs, all of which are processed fine except for one record for which I get the error - Record member already locked to this job.
    I dont understand this, the program reads file A, set key for file B, chains file B, checks and updates file B, and so on. The program has fallen over twice on the same file B record.
    I have put an UNLOCK on file B, if it does not meet the conditions and hence would not be updated. No luck, still get the same errors.

    Devarshi.

  • #2
    Re: I/O error while chaining due to rec lock

    Please post a small snippet of code so we can take a shot at it.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: I/O error while chaining due to rec lock

      What do you mean by "sets key for file B" - are you using both SETLL and CHAIN ?

      Comment


      • #4
        Re: I/O error while chaining due to rec lock

        The code is as follows -
        PHP Code:
        Setll (@Jur:#store) PLBSDML1;       
        Dou %eof(PLBSDML1);                 
            
        ReadE (@Jur:#store) PLBSDML1;   
            
        If %found (PLBSDML1)            
            And 
        PXprom <> *Zero             
            
        Or  PXprce <> *Zero;            
                                            
                @
        Prom  PXprom 100;      
                @
        Prce  PXprce 100;      
                @
        Sku_Zone PXskun;         
                @
        Store = %Dec(PXstor:4:0);  
                                            
                
        // Get other key details    
                
        Chain (@Sku_ZonePCMSKUDP
                If %
        Found (PCMSKUDP);       
                    
        Chain (@Store:SKstyl:SKcolrPCMSTRDP;  
                    If %
        Found;                                  
                    If  @
        Prom  <> 0;                                       
                        
        STnppc = @Prom;         // New promotion price     
                        
        Update RPCMSTRD;                                   
                     Else;                                     
                      If @
        Prce  <> 0;         
                        
        STnmpr = @Prce;          // New promotion price  
                        
        Update RPCMSTRD;                                 
                    Else;     
                        
        Unlock PCMSTRDP;         //DV01//                
                    
        EndIf;                                               
                    EndIf;                                               
                    EndIf; 
        The reocrd lock occurs during chain to PCMSTRDP

        Thanks
        Devarshi.

        Comment


        • #5
          Re: I/O error while chaining due to rec lock

          Your problem is probably the READE. READE does not support or reset %Found. You prob should be using
          If NOT %EOF instead of If %Found

          Comment


          • #6
            Re: I/O error while chaining due to rec lock

            Correct arrow;

            Chain uses %Found(File) and Read or ReadE uses %EOF(File).
            Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

            Comment


            • #7
              Re: I/O error while chaining due to rec lock

              READE is on file PLBSDML1 which is an input file only. The problem occurs on the second Chain, i.e
              Chain (@Store:SKstyl:SKcolr) PCMSTRDP;

              Devarshi.

              Comment


              • #8
                Re: I/O error while chaining due to rec lock

                You miss my point. You have

                ReadE (@Jur:#store) PLBSDML1;
                If %found (PLBSDML1)

                You ARE reading PLBSDML1, but the %found status of PLBSDML1 is not getting reset here. I suspect the code is executing when its not supposed to.

                Comment


                • #9
                  Re: I/O error while chaining due to rec lock

                  Change your "If %Found;" to have a file in the function; "If %Found(PCMSTRDP);"
                  Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                  Comment


                  • #10
                    Re: I/O error while chaining due to rec lock

                    I was going to include the file name after the 'If %Found'. The job will run tomorrow morning so will find out if that does it. Thank you all, will keep you posted.

                    Devarshi.

                    Comment


                    • #11
                      Re: I/O error while chaining due to rec lock

                      Another potential problem

                      Setll (@Jur:#store) PLBSDML1;
                      Dou %eof(PLBSDML1);


                      SETLL does not seton the %eof if not found. And the DOU operation will make the code execute once, even if the %eof was on from a prior operation.

                      SETLL does use the %found, so ...

                      Setll (@Jur:#store) PLBSDML1;
                      DoW %Found(PLBSDML1);
                      ReadE (@Jur:#store) PLBSDML1;
                      If NOT %eof(PLBSDML1)
                      And PXprom <> *Zero
                      Or PXprce <> *Zero;

                      Where do you read/chain/setll file PLBSDML1 so that the DOU/DOW test works the 2nd pass thru ?

                      Comment


                      • #12
                        Re: I/O error while chaining due to rec lock

                        I have an ENDDO at the end.

                        Devarshi.

                        Comment


                        • #13
                          Re: I/O error while chaining due to rec lock

                          Maybe I'm confusing it here. Here's your orig code

                          Setll (@Jur:#store) PLBSDML1;
                          Dou %eof(PLBSDML1);
                          ReadE (@Jur:#store) PLBSDML1;
                          If %found (PLBSDML1)


                          Now, the dou %eof is testing the result of the READE (from the previous time thru, since the ReadE hasn't happened yet). And the %found is testing the result of the Setll that occurred outside the do loop. The dou command forces the do loop to execute thru the first time (no matter when %eof status is) and tests the %eof status at enddo time. But when it loops back, the setll doesn't execute again, so %found never gets reset.

                          I think you will find the loop will work ok, until a "bad" record follows a "good" record, then it will execute when you don't want it to.

                          How about

                          Setll (@Jur:#store) PLBSDML1;
                          If %found(PLBSDML1)

                          Dou %eof(PLBSDML1);
                          ReadE (@Jur:#store) PLBSDML1;
                          If NOT %eof(PLBSDML1)
                          ..... do stuff ...
                          endif
                          enddo

                          endif

                          The second %eof test is needed because DOU doesn't test its status until the do loop completes.

                          Comment


                          • #14
                            Re: I/O error while chaining due to rec lock

                            Originally posted by Devarshi View Post
                            READE is on file PLBSDML1 which is an input file only. The problem occurs on the second Chain, i.e
                            Chain (@Store:SKstyl:SKcolr) PCMSTRDP;

                            Devarshi.
                            One more possibility for this to happen is that you might have a chain on this file in some other part of the code which would have taken a record lock as the file is opened in update mode.
                            Regards,
                            KR

                            Comment


                            • #15
                              Re: I/O error while chaining due to rec lock

                              Morning all, I'm still having problems. Out of 400,000 records, its the same record that is being locked on all three runs.
                              I had changed to code as -
                              PHP Code:
                              Open PLBSDML1;                                                        
                              Setll (@Jur:#store) PLBSDML1;                                         
                              Dou %eof(PLBSDML1);                                                   
                                  
                              ReadE (@Jur:#store) PLBSDML1;                                     
                                  //If %found (PLBSDML1)       DV02//                               
                                  
                              If not %EOF (PLBSDML1)     //DV02//                               
                                  
                              And PXprom <> *Zero               // Exclude Promotion price zero 
                                  
                              Or  PXprce <> *Zero;              // Exclude Permenemt price zero 
                                                                                                    
                                      
                              @Prom  PXprom 100;                                        
                                      @
                              Prce  PXprce 100;                                       
                                      @
                              Sku_Zone PXskun;                                          
                                      @
                              Store = %Dec(PXstor:4:0);                                   
                                                                                                   
                                      
                              // Get other key details                                     
                                      
                              Chain (@Sku_ZonePCMSKUDP;                                  
                                      If %
                              Found (PCMSKUDP);          //DV02//                      
                                       
                              Chain (@Store:SKstyl:SKcolrPCMSTRDP;   // Store file   
                                          
                              If %Found (PCMSTRDP);      //DV02//                      
                                          
                              If  @Prom  <> 0;                                         
                                              
                              STnppc = @Prom;         // New promotion price       
                                              
                              STcprr = @Prom;         // Currect price             
                                              
                              STprfg '1';           // promotion flag            
                                              
                              STmkdw ' ';           // markdown flag             
                                              
                              STpldt = %Char(PXPRCH); // promotion start date      
                                              
                              STpedt '        ';    // promotion end date        
                                              
                              Update RPCMSTRD;                                     
                                                                                                   
                                           
                              //EndIf;  DV01//                                      
                                           
                              Else;     //DV01//                                    
                                           //If  @Prom  = 0    DV01//                            
                                           //and @Prce  <> 0;   DV01//                           
                                           
                              If @Prce  <> 0;   //DV01//                            
                                               
                              STcprr = @Prce;          // Currect price         
                                               
                              STlmpr STnmpr;         // Last promotion price  
                                               
                              STnmpr = @Prce;          // New promotion price   
                                               
                              STprfg ' ';            // promotion flag        
                                               
                              STmkdw '1';            // markdown flag         
                                               
                              STmldt = %Char(PXPRCH);  // markdown date         
                                               
                              Update RPCMSTRD;                                  
                                           Else;     
                              //DV01//                                    
                                               
                              Unlock PCMSTRDP;         //DV01//                 
                                           
                              EndIf;                                                
                                           EndIf;                                                
                                           EndIf; 
                              I have included file names after read and chain, also 'not %eof' after reade instead of %found. Still fell over with I/O error with file PCMSTRDP.
                              The strange thing is that its the sam SKU value that is locked, and this program is called 3 times, for different stores and in each case its the same sku.
                              The sku itselt looks fine.

                              Please help
                              Devarshi.

                              Comment

                              Working...
                              X