The Classic database server has deadlock protection that prevents the system from locking. To prevent individual users from experiencing deadlock, however, certain tables must be locked in a specific order. In the base application, there are four main groups of tables to consider:

Journals

You must lock tables on the lowest level first. A journal has three levels. Templates are on the highest level. Batch names are on the next level. Lines are on the lowest level. When you want to delete a journal template, the application first deletes the journal lines and implicitly locks them. It will then repeat the process with the batch names. You can then delete the template. The rule results in this locking order:

  1. Journal line

  2. Batch name

  3. Journal template

Nonposted Lines and Headers

Because database consistency in the application is very important, there is another rule that must be followed when sales lines are locked before the corresponding sales header. When a user tries to insert a new sales line, the Sales Line table is automatically locked. Another user cannot delete the sales header at the exact same time because the sales lines must be deleted before a sales header can be deleted. Because of this, there will never be sales lines without a corresponding sales header. The same is true for purchase headers and lines. The locking order is as follows:

1. Sales Line table/Purchase Line table

2. Sales Header table/Purchase Header table

Posted Lines and Headers

You must also respect a locking order when working with both posted headers and lines and with headers and lines that are not yet posted. The main principles are that posted headers are locked before posted lines, and purchase tables are locked before sales tables. Posted tables are locked before nonposted tables. These principles result in the following locking order:

1. Purch. Rcpt. Header

2. Purch. Rcpt. Line

3. Sales Shipment Header

4. Sales Shipment Line

5. Sales Invoice Header/Sales Cr. Memo Header/Purch. Inv. Header/ Purch. Cr. Memo Hdr.

6. Sales Invoice Line/Sales Cr. Memo Line/Purch. Inv. Line/ Purch. Cr. Memo Line

7. Purchase Line

8. Purchase Header

9. Sales Line

10. Sales Header

Ledger Entries and Registers

A ledger entry table must always be locked before its corresponding register table. For example, you must lock the G/L Entry table before the G/L Register table.

See Also