Command Buffer

Microsoft Dynamics Nav 2009

The command buffer only applies to Classic Database Server. It is placed as a link between your application and the DBMS and is temporary storage that can hold requests or C/AL database commands that are sent from your application to the DBMS. The command buffer has been designed to reduce the number of network transfers when using C/SIDE in local area network (LAN) environments.

The Command Buffer and Network Transfers

When an application performs a write transaction, some requests such as inserting a record in a table by using record.INSERT do not need to be sent to the DBMS immediately. They can be temporarily stored in a command buffer. In general, the commands that do not have to be sent to the DBMS immediately are the commands that do return a value.

NoteNote

The contents of the command buffer are sent to the DBMS when the buffer is full or when a command requires an immediate response from the DBMS.

The advantage of assembling DBMS commands into packages is that the number of network transfers and the load on the LAN is reduced. The time that is required to send one DBMS request is comparable to the time that is used to send an entire package.

The following C/AL code example illustrates how the command buffer affects the number of network transfers.

WHILE Record.FIND('-') DO
Record.DELETE();

Two commands are executed for each record in the table. However, each record causes only one request to be sent to the DBMS because the DELETE command is stored in the command buffer until the FIND command is executed.

Debugging

The command buffer is turned off when you activate the C/AL debugger.

For example, the following statements illustrate the difference between running code with and without the debugger.

Customer."No." := '12';
Customer.DELETE();
First := 7;
Second := 0;
Ratio := First / Second;

If there is no customer with the number 12, then a run-time error occurs regardless of whether the debugger is active. However, the error that occurs is not the same. There are two errors because the customer cannot be found:

  • The DELETE statement will fail.

  • The last statement is a division by zero.

When the debugger is inactive, the DELETE command is stored in the command buffer for execution at a later time. Therefore, a run-time error occurs when the last statement tries to divide by zero.

When the debugger is active, the DELETE command is executed immediately. This causes a run-time error when the record for customer number 12 cannot be found.

See Also

Community Additions

ADD
Show: