StatusWin.OPEN('Inserting test records\Record #1#############'); FOR I := 50000 TO 100000 DO BEGIN StatusWin.UPDATE(1,I); Rec.INIT; //Rec.ID := I; Rec.RandomCode := 'AHJYEFASEJ'; Rec.RandomText := 'sdf;alkjewrkewj;we'; RANDOMIZE(); Rec.SomeNumber := 100 * 100 / 5 + 200 + RANDOM(1000); Rec.DateTime := CURRENTDATETIME(); Rec.INSERT(TRUE); END; StatusWin.CLOSE;For some reason every time I try to run this code I'll get an error of:
where x = the next available number. When this happens it never actually inserts any records, however, it does increase the autoincrement seed number. Anyone know why this would happen?The Test Entry already exists.
Identification fields and values:
ID='x'
Comments
Microsoft Dynamics NAV Developer
regards
I traded my sanity for a railgun
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I traded my sanity for a railgun
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I traded my sanity for a railgun
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Microsoft Dynamics NAV Developer
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
It is not weird if you take it from SQL point of view. This field has connected some identity (step, seed, etc.). This is some counter which is automatically increased when new record is inserted. When you insert record with this field filled in with some value, to prevent inserting same value through autoincrement, the counter must be set to this new manually inserted value to continue in counting. Bud because this identity is part of metadata of the table, you need to have enough rights to do that.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
========================
Do not forget that INIT don't clear fields of primary key! To be able to use autoincrement, you need to assign 0 to the PK field before you do INSERT.
_________________
Kamil Sacek