AddIDField()

Summary

Adds an ID field to an existing table.

Syntax

AddIDField(string view_name, integer start, integer step, boolean indexed_flag, string newfldname, string where, array options)

Argument Contents
view_name The name of the view of a table; if omitted, the current table is used
start The index of the first element; if omitted, indexing starts at 1
step The increment to use (the default is 1)
indexed_flag If the new ID field is to be a permanent index to the table (the default is "False")
newfldname The proposed name of the new ID field (the default is "ID")
where Indicates where to place the new ID field. This can be "left" or "right", meaning the field will be the leftmost or rightmost field of the table, or "auto" (the default), which means the choice of leftmost or rightmost position will be made automatically

No options are currently supported.

Returns

The actual name of the field that was added.

Notes

  • If the table already has a field named newfldname, the name will be suffixed with ":1", ":2" etc., as necessary to obtain a unique field name.

  • When choosing leftmost/rightmost position automatically (where="auto"), the function takes into account the type of the database, and the currently indexed fields. The choice is made in such a way as to minimize the amount of re-indexing of the original fields.

  • The ID field is a long (4-byte) integer.

Example

fld_name = AddIDField("MyTable", 1000, 1, "False", "NewID", "auto", )

Error Codes

Error Type Meaning
NotFound No view with this name was found, or no current view was found
Error The table cannot be modified