Locktable and commit

IBS
Member Posts: 29
Hello
Just to confirm
When I issue a locktable and then a commit,
Does the commit releases the lock on the table? If not when does it release the lock?
Just to confirm
When I issue a locktable and then a commit,
Does the commit releases the lock on the table? If not when does it release the lock?
0
Comments
-
Yes, commit will release the locks. But, please, think about it before you use the commit in your code. It can make bigger problems than solve....0
-
a commit fired up an Transaction end to the SQL Server. so, the locks into the transaction are released. But like kine sayed. You must know when you set the commit.
Better, for the lock problem, check why there are locks. Is there are "stupid" keys like under "dimensions", there are many SIFTs to create / delete / update, there are many recs to update / delete / create, is the C/AL Code not good enought for a better perfomance, etc :?:
so, you see, many question, for one little post ;-)
RegardsDo you make it right, it works too!0 -
Well the code is not mine and I'm trying to solve locktable issue.
The code is like this. The table has "entry no." as PK
Table.Locktable.
if table.findlast then;
LastEntryNo := table."Entry No." + 1;
table.reset;
table."Entry No." := LastEntryNo;
table."Populate other fields"
table.insert;
commit;
form.runmodal(0,table);
What is a good way to solve the locktable issue.0 -
This is not "locktable" issue, it is FORM.RUNMODAL issue... ;-)0
-
IBS wrote:Well the code is not mine and I'm trying to solve locktable issue.
The code is like this. The table has "entry no." as PK
Table.Locktable.
if table.findlast then;
LastEntryNo := table."Entry No." + 1;
table.reset;
table."Entry No." := LastEntryNo;
table."Populate other fields"
table.insert;
commit;
form.runmodal(0,table);
What is a good way to solve the locktable issue.
back to the start... What are you trying to archive. It looks like you are trying to get user interaction during a transaction. Much like that absolutely awful bit of code that checks the credit status of a client when entering a sales order.
You need to rethink the business logic and redesign it.
Not all business requirement can be solved by code unfortunately. And its even worse when you have existing code you need to work with.David Singleton0 -
This is not during any transaction (posting). The data gets prepopulated before the form is opened. Thats all it is.
The user then populates additional data and closes the form.0 -
Anyway, it is a transaction (Data Create) ;-) And you can't run a form / report in Runmodal mode during a transaction, so u use the commit to end the transaction.
So, but where is there the problem with the commit? OK, its not very nice, but the first transaction is to insert the recs. Is this finish, end the Transaction (commit). After the commit is a form runmodal. These runmodal doesn't block other users (if there is no locking code in the form), it's the same thing when he fill the table behind Button1 and call the form from Button 2. Both are sep. transactions. It's the same thing when he run first the form and insert from there the Recs with using a function on Form, like, Function -> "Insert Recs from Anywhere"
Do you have seen where the blocks occur :?: And which table is locked? the table where u insert or a other table?
RegardsDo you make it right, it works too!0 -
IBS wrote:This is not during any transaction (posting). The data gets prepopulated before the form is opened. Thats all it is.
The user then populates additional data and closes the form.
Then I think you need to be a bit clearer in what you are doing. As Garak has said, if this is not in the middle of a transaction, then no locking should be occuring. It could be that you are on a "bad" version, so let us know which NAV version you are on , service paks updates and hot fixes.
ALso take a look at Waldo's Blog, to see where you need to be:
Platform updates overviewDavid Singleton0
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
- 320 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