Set Table statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Configures various settings of an open table. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Set Table tablename 
	[ FastEdit { On | Off } ] 
	[ Undo { On | Off } ]
	[ ReadOnly ] 
	[ Seamless { On | Off } [ Preserve ] ] 
	[ UserMap { On | Off } ] 
	[ UserBrowse { On | Off } ] 
	[ UserClose { On | Off } ] 
	[ UserEdit { On | Off } ] 
	[ UserRemoveMap { On | Off } ] 
	[ UserDisplayMap { On | Off } ]
	[ Persist { On | Off } ]
	[ Datum datum_number ]
	[ Description layer_name ]
	[ InUse { ReadAccess | WriteAccess | Off } unique_token ]
	[ ReDraw { On | Off } ]
	[ Adopt Transaction ]

tablename is a string representing the name of the table to be set.

layer_name is a pretty or friendly name for a layer.

unique_token is a string that will be used again when marking the table as no longer in use.

Adopt Transaction, allows adoption of transaction files created by MapXtreme.NET on a table opened in MapInfoPro.

Description

The Set Table statement controls settings that affect how and whether a table can be edited. You can use Set Table to flag a table as read-only (so that the user will not be allowed to make changes to the table). You can also use Set Table to activate or de-activate special editing modes which disable safety mechanisms for the sake of improving editing performance.

Datum writes the datum index information for native tables into the map file, including the ellipsoid index, three shift parameters, three rotation parameters, and scale parameter. Some datums are identical, so this statement keeps the datum index along with all datum parameters in memory and writes it into the map file.

The Persist Off clause marks a table, so that it will not be written to the workspace when a workspace is saved. The Persist or Persist On clause marks a table, which was previously marked as Persist Off, so that it will be written back to the workspace when a workspace is saved.

Description assigns a default pretty (friendly) name to a layer by using the Description field (part of Definition section) in a TAB file currently open in MapInfo Pro. To delete an open TAB file's Description property, use an empty string:
Set table tablename description ""

The InUse clause protects a table so that it cannot be closed or edited while you are using it. This is useful when running background tasks on tables, so that they cannot be updated until you mark them as not in use. The ReadAccess and WriteAccess tokens let you specify what sort of access is available for a table when it is in use. The Off token marks a table as not in use. A unique string, unique_token, must be used when marking the table as in use and the same string is used to mark the table as not in use. To tell if a table is in use, use the TAB_INFO_INUSE attribute with the Set Table statement. Consider the following when using this clause:

  • A table can be marked as in use with write access only once. Write access is exclusive, the table can be marked in use again only after it has been marked as not in use.
  • A table can be marked with read access multiple times by multiple tasks using different token strings.
  • When multiple tasks have marked a table as in use, all of those tasks must mark it as no longer in use before the table to be considered not in use.
  • A table with pending edits cannot be marked as in use. All edits need to be saved or deleted first.
  • Read only tables cannot be marked as in use with write access.
  • A table using fast edit mode cannot be marked as in use with write access.
  • Seamless and Raster tables cannot be marked in use.
  • If a query table is marked as in use, its base table is considered in use and all its dependent tables (queries) are not editable, but can be closed.
  • If a join table is marked in use, all its base tables are considered in use and their dependent tables (queries) are not editable, but can be closed.

Setting FastEdit Mode

Ordinarily, whenever a table is edited (either by the user or by a MapBasic application), MapInfo Pro does not immediately write the edit to the affected table. Instead, MapInfo Pro stores information about the edit to a temporary file known as a transaction file. By writing to a transaction file instead of writing directly to a table, MapInfo Pro gives the user the opportunity to later discard the edits (for example, by clicking the Revert Table command).

If you use the Set Table statement to set FastEdit mode to On, MapInfo Pro writes edit information directly to the table, instead of performing the intermediate step of writing the edit information to a transaction file. Turning on FastEdit mode can make subsequent editing operations substantially faster.

While FastEdit mode is on, table edits take effect immediately, even if you do not issue a Commit Table statement. Use FastEdit mode with caution; there is no opportunity to discard edits by clicking the Close or Revert Table commands.

You can only turn FastEdit mode on for normal, base tables; you cannot turn on FastEdit for a temporary, query table such as Query1. You cannot turn on FastEdit mode for a table that already has unsaved changes. You cannot turn on FastEdit mode for a linked table.

CAUTION:
While a table is open in FastEdit mode, other network users cannot open that table. After you have completed all edits to be made in FastEdit mode, issue a Commit Table statement or a Rollback statement to reset the file so that other network users can access it.

If you include the optional ReadOnly clause, the table is set to read-only, so that the user cannot edit the table for the remainder of the MapInfo Pro session. The Set Table statement does not allow you to turn read-only mode off. You can also activate read-only mode by adding the ReadOnly keyword to the Open Table statement.

Ordinarily, whenever an edit is made, MapInfo Pro stores information about the edit in memory, so that the user has the option of choosing the Undo command. If you use the Set Table statement to set Undo mode to Off, MapInfo Pro does not save undo information for each edit; this can make subsequent editing operations substantially faster.

Managing Seamless Tables

A seamless table defines a list of other tables that you can treat as a group. See the MapInfo Pro documentation for an introduction to seamless tables.

The Seamless clause enables or disables the seamless behavior for a table. Specify Seamless Off to disable seamless behavior, so that you can access the individual rows that define a seamless table. Specify Seamless On to restore seamless behavior. If you include the Preserve keyword, the effect is permanent; MapInfo Pro writes a change to the table. If you omit the Preserve keyword, the effect is temporary, only lasting for the remainder of the session.

The User... clauses allow you to limit the actions that the user can perform on a table. These clauses are useful if you want to prevent the user from accidentally opening, closing, or changing tables or windows.

These clauses limit the user-interface only; in other words, UserMap Off prevents the user from opening the table in a Map window, but does not prevent a MapBasic program from doing so.

Note: You cannot use these clauses on Cosmetic layers.
Example Effect
UserMap Off Table will not appear in the New Map Window or Add Layer dialog boxes.
UserBrowse Off Table will not appear in the New Browser Window dialog box.
UserClose Off Table will not appear in the Close Table dialog box.
UserEdit Off Table will not be editable through the user interface: Browser and Info windows are not editable, and the map layer cannot be made editable.
UserRemoveMap Off If this table appears in a Map window, the Remove Layers button (in the Layer Control window) is disabled for this table.
UserDisplayMap Off If this table appears in a Map window, the Visible On/Off check box (in the Layer Control window) is disabled for this table.

Temporarily Suspending Map Redraws

The ReDraw clause suspends redrawing the map when there are changes to a table, such as for insert, update, or delete operations. This is useful when processing multiple table updates, because it is more efficient to delay updating the Map window until after updating the tables. This can significantly improve overall processing time depending on the complexity of the map and the table update action.

The ReDraw clause wraps a set of table updates as shown in this example:

Set Table Test REDRAW OFF
For I = 1 to 1000
	'  Insert | Update | Delete statement against Test
Next
Set Table Test REDRAW ON

Examples

The following statement prevents the World table from appearing in the Close Table dialog box.

Set Table World UserClose Off
Marking a Table as In Use

The following statement marks a table named CN21 as in use. The unique string is "cn21abc".

Set table CN21 inuse readaccess "cn21abc"

Mark the table named CN21 for write access. Continue to use the unique string "cn21abc".

Set table CN21 inuse writeaccess "cn21abc"

After running background tasks on the CN21 table, it is released and made available to other processes and users.

Set table CN21 inuse off "cn21abc"