DatasetModelClass Throwing Error
 
Forums / SmartComponent Library - Developer Forum / DatasetModelClass Throwing Error

DatasetModelClass Throwing Error

7 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    24 Mar 2020
    Link to this post
    I am using a dataset model class to create/update records in a table. I am getting a bunch of conflicting record errors. I have no idea as to why. Do you see an issue with the usage of that class in the internal procedure below?


    [20/03/24@09:06:53.770-0400] P-011436 T-010320 1 4GL ORS_ERR        An Progress.Lang.AppError has occurred:
    [20/03/24@09:06:53.770-0400] P-011436 T-010320 1 4GL ORS_ERR        Error received from procrebatecustomermaint.r A conflicting RebateCustomer record already exists with CustomerNum 40037590 RebateId "19"!
    [20/03/24@09:06:53.770-0400] P-011436 T-010320 1 4GL ORS_ERR          Table: eRebateCustomer
    [20/03/24@09:06:53.770-0400] P-011436 T-010320 1 4GL ORS_ERR       


    /* **********************  Internal Procedures  *********************** */
    PROCEDURE ProcessAddUpdate PRIVATE:
    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/
     DEFINE VARIABLE oRebateCustomer AS Osprey.Pos.RebateCustomer.RebateCustomerDatasetModel NO-UNDO.
     
     DO ON ERROR UNDO, THROW:
      
      /* Roger Blanchard / Osprey Retail Systems Nov 6, 2019
       new our class and use OVERLOAD to find RebateCustomer using CustomerNum and RebateId during instantiation
      */
      oRebateCustomer = NEW Osprey.Pos.RebateCustomer.RebateCustomerDatasetModel (dCustomerNum,
                                                                                  cRebateId
                                                                                  ).
      
      oRebateCustomer:TrackingChanges = TRUE.
      
      IF NOT oRebateCustomer:RebateCustomer:Available THEN
      DO: 
       oRebateCustomer:RebateCustomer:Create().
       oRebateCustomer:RebateCustomer:CustomerNum = dCustomerNum.
       oRebateCustomer:RebateCustomer:RebateId  = cRebateId.
      END. 
      
      oRebateCustomer:RebateCustomer:BufferHandle:BUFFER-COPY(hQuery:GET-BUFFER-HANDLE(1),
                                                              "CustomerNum,RebateId" // except list as we already assigned above
                                                              ).
      
      oRebateCustomer:SaveChanges().   
      
      CATCH e AS Progress.Lang.Error:
       UNDO, THROW e.
      END CATCH.

      FINALLY:
       DELETE OBJECT oRebateCustomer NO-ERROR.
      END FINALLY.
      
     END.
    END PROCEDURE.
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    24 Mar 2020 in reply to Roger Blanchard
    Link to this post
    Do you get the conflicting records in case of 

    IF NOT oRebateCustomer:RebateCustomer:Available THEN

    or when the record is available?

    Any suspicious code in the Business Entity or Data Access class? What's your AssignSkipList?
  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    24 Mar 2020 in reply to Mike Fechner
    Link to this post
    This is occurring when the record is already on the DB. I can add some logging to see if the DatasetModel class thinks it is available.

    The BE is what was created from the designer. No addl code added to ValidateData or ReceiveData.

    As far as the DA we do have the validation hook methods defined but they are not being used. I can remove all that and try again.

    We are not using assignskiplist
  4. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    24 Mar 2020 in reply to Mike Fechner
    Link to this post
    Every time it happens the dataset model class cannot fetch so we then try to create. Since the record is already in the DB we get this error. 

    [20/03/24@17:03:25.252-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint>:  Begin
    [20/03/24@17:03:25.252-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint>:  TRANSACTION=no
    [20/03/24@17:03:25.257-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint  ProcessAddUpdate>:  Begin...dCustomerNum=40441804...cRebateId=19
    [20/03/24@17:03:25.262-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint  ProcessAddUpdate>:  RebateCustomer does not exist so create
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint  ProcessAddUpdate>:  End
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_DBG        <procRebateCustomerMaint>:  End
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_ERR        An Progress.Lang.AppError has occurred:
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_ERR        Error received from procrebatecustomermaint.r A conflicting RebateCustomer record already exists with CustomerNum 40441804 RebateId "19"!
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_ERR          Table: eRebateCustomer
    [20/03/24@17:03:25.266-0400] P-012092 T-002688 1 4GL ORS_ERR       
  5. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    Answered
    25 Mar 2020 in reply to Roger Blanchard
    Link to this post
    When the DatasetModel does not return the record although it's there, please double-check that the constructor of the DatasetModel uses the right fields to filter.

    Please enable detailled Data Access logging, to verify the database queries as well.

    Please also check if the Business Entity is implementing the IFetchDataByReference interface and the FetchDataByReference method is implemented according to the template for Business Entities.
  6. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    25 Mar 2020 in reply to Mike Fechner
    Link to this post
    Will do. We cannot duplicate in our office but it is occurring at all 37 sites we just implemented this in. It must be something specific to their DB. We have requested a backup of their DB to load up in our office.

    thanks,
  7. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    25 Mar 2020 in reply to Mike Fechner
    Link to this post
    Hey Mike,

    We finally received a backup of the customers DB and the issue is their DB. The RebateCustomer table has a JOIN to another table and for some reason the customer's DB is missing the JOINED record resulting in the RebateCustomer record to not be available.

    Our reseller support rep fixed the DB issue 30 minutes ago and now the record is available as it should be. 

    We are updating the DataAccess class to use an OUTER-JOIN as well.

    Thanks for the support.

    Stay safe!!
7 posts, 1 answered