Hello,
I understand the principle of COMMIT but have been unable to simulate it use.
I completed the following experiment with no success, please advise where I am am going wrong.
1. Create a table consisting of a Primary Key and a field named description.
2. I then wrote a codeunit which inserted one record in the above table.
3. I then used SETFILTER to locate the new record followed by a FIND which was successful.
QUESTION: I was told that if I wanted to write a record then read it in the same report or codeunit that I would need to write the record then use the COMMIT before attemptint to read. If I don't do use the COMMIT then the record will not exist until I leave the report or CODEUNIT.
Thanks
0
Comments
Commit is not about visibility of inserted records. It is about ATOMIZATION. All what you are doing in NAV is running as a "Transaction" (SQL terminus technicus). Everything during the transaction is assumed as atom - if something fail, all failed. It means if you have error during this transaction, no change done in this transaction will be made - this is named ROLLBACK of the transaction. If all is OK and the process finished, transaction is COMMITED. It means that all data created/updated/deleted during this transaction are permanently saved into the Database and released for other processes. And the COMMIT command is something which will do that commit when you want. And this is very dangerous.
I am sure that you can read more about the transactions in database systems, or about NAV transactions in the NAV documentation etc. to know more. But main thing is that you can see your inserted/modified/deleted records during your own transaction without problems.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Well, in general NEVER EVER USE COMMIT, this way you will be sure
that your tranactions is allways complete.
- Use commit when you fetch a number from a number series.
take a look in code unit 80.
IF ModifyHeader THEN BEGIN
MODIFY;
COMMIT;
This is done to release the number series table as it's locked from the time the number series table was MODIFYed.
BR Per
- When you send a
In Codeunti A.RUN, write code below:
TableA.INIT;
TableA.Code :='100';
TableA.Name :='Test';
TableA.INSERT;
TableA2.GET('100');
MESSAGE(TableA2.Name);