Hi,
We are doing something like this on a table:
TableRec.SETRANGE("Field1", 'XXXX');
If TableRec.FINDSET() THEN REPEAT
TableRec.DELETE(TRUE);
UNTIL Table.NEXT() = 0;
This set of code looks to be doing something like a table lock - If I end up running this routine at the same time on another instance of navision classic (6.0) with a different range (i.e. 'YYYY' instead of 'XXXX'), the second instance of navision will end up with a "Another User Has Locked TableRec". I think this is related to SERIALIZATION ?
Thanks for any help.
Mega
0
Comments
Try to rewrite code with setcurrentkey("Field1") or use temporary table.
Nav, T-SQL.
Well, that fixed it !
I had been told that sql picks the keys to use for navision operations automatically, but I guess that's really not the case.
Thanks,
Mega
Nav, T-SQL.
Thanks - I got some bad advice regarding this. I'll be putting fixes in.
I remember 5 years ago each NAV build had different best practices.
Now (last years) they fixed it back to SQL prefering the SETCURRENTKEY to be there, it behaves more like the old Native database.
This is a pretty significant change, so let's hope no changes in the future.
And NAV doesn't use "Field1" as default if not specified in code?
If you do for example
SELECT * FROM CUSTOMER WHERE ADDRESS = 'XX' ORDER BY NO
or
SELECT * FROM CUSTOMER WHERE ADDRESS = 'XX' ORDER BY ADDRESS
SQL Server is more likely to use the index in the second example.
But why did it help the TS to add setcurrentkey() ? That's automatically the default? :-k
When we do an update for records, we expect the primary key to be used.
As a result we do not use setcurrentkey(..with primary field...) as it's already used by default.