How to use COMMIT
 
            
                
                    icarus1306                
                
                    Member Posts: 14                
            
                        
            
                    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
                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
- 
            It is not true... :-)
 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.0
- 
            Hi
 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 a0
- 
            See below code,It works well,so I don't think you need to use COMMIT,and why did you meet an error?
 In Codeunti A.RUN, write code below:
 TableA.INIT;
 TableA.Code :='100';
 TableA.Name :='Test';
 TableA.INSERT;
 TableA2.GET('100');
 MESSAGE(TableA2.Name);0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


