Incredibly strange error from COUNT function

DakkonDakkon Member Posts: 192
I'm running into a bizarre situation where calling COUNT on a table is generating a very unexpected error. The error is as follows:
The Dynamic Move Line already exists. Identification fields and values: ...

As you can see, this is the typical error that you would get when attempting to insert a duplicate key entry into a table. The error is raised from the following code line:
IF DynamicMoveLine.COUNT > 1 THEN

What makes this yet even stranger is that prior to this code (in my test case) I have called DELETEALL before inserting a single line. Obviously if all the records are deleted and one entry is then inserted, there should be no key collision. I have never in my life seen Navision generate a "line already exists" error from a call to the COUNT function. I'm assuming this must be a bug in the new RTC nav engine. Has anyone else seen this happen? Does anyone know what is going on here?
Thad Ryker
I traded my sanity for a railgun :mrgreen:

Best Answer

Answers

  • DakkonDakkon Member Posts: 192
    Thank you Kishorm, the explanation is much appreciated. I'm still puzzled as to how it is encountering a duplicate record on insert (given that I'm calling DELETEALL prior), but that is a separate issue.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • KishormKishorm Member Posts: 921
    No problem!

    After your DELETEALL you must be INSERTing some records (otherwise there'd be no point doing a COUNT?) so it's during these INSERTs that you are adding 2 records with the same key.
  • DakkonDakkon Member Posts: 192
    Actually it turned out to be an issue in the filters applied before the DELETEALL. I was actually only inserting one record because it was a test scenario, the COUNT check is there for production situations, but I was simply trying to test a specific scenario. The issue was that the incorrect filters resulted in not all of the existing records being deleted that I had expected.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
Sign In or Register to comment.