KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utilizing READ ONLY mode
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: December 8, 2017

Access to tables in read-only mode is faster and more memory efficient, and changing the state of a table is optimized in client/server mode as it does not cause any additional network traffic. Information is only sent to the server when executing a command that requires adequate access to the table. Due to this fact, it is good practice to place all tables in read-only mode when each process is started, and then put each table in read/write mode only when necessary.

To put all tables in read-only mode use the command: READ ONLY(*)

To make an update to a record in a table, delete a record, or lock a record for other users, put that table in to read/write mode using the command: READ WRITE([Table_1])

To put the table back into read-only mode again, use the command: READ ONLY([Table_1])

To check the state of a table, use the command Read only state([Table_1]) which will return a boolean TRUE if the state of the table is read-only, or FALSE if the state of the table is read/write.

Note: The READ ONLY and READ WRITE commands are not retroactive, meaning that a record is loaded according to the table's read/write status at the time of loading. To load a record from a read-only table in read/write mode, the state of the table must first need to be set to read/write.

A simple example of this concept:

If(Read only state([Table_1])
   READ WRITE([Table_1])
   FIRST RECORD([Table_1])
End if

// do something with record(s) in the [Table_1] table

READ ONLY([Table_1])