Previous Topic

Next Topic

UpgradeTable - MaxBasic Function

UpgradeTable(TableFileName: String, TemplateFileName: String[, UpdateFields: Boolean, ReplaceSchema: Boolean]): Boolean

Uses an XML Schema file TemplateFileName to upgrade or create a table. If TableFileName is not found, a new .ADB table file will be created. If TableFileName is found, the table will be upgraded.

The TableFileName file is saved in the data directory. TemplateFileName must be a fully specified path. Template files can be generated using the GenerateSchema function.

The function returns True if the upgrade was successful, or False if it was unsuccessful.

Default without optional parameters specified (or both false) is non-destructive upgrade, i.e. from the template schema, add a new table or add fields to an existing table or add indexes to an existing table or make existing string fields bigger.

Note:

UpgradeTable function syntax has these named arguments:

Parameter

Description

Table File Name

Required. The file name of the table in the data directory to be created or upgraded.

Template File Name

Required. The template used to upgrade the table.

Update Fields

Optional, default false. If true then field types and sizes will change to match the template schema - this could lose or corrupt data.

Replace Schema

Optional, default false. If true then make the old table match the template schema and do the best effort with copying data.

For existing tables, any fields that are not included in the XML schema file and have not been renamed to match new Custom fields added in the schema will be dropped and data in these fields will be lost. This also applies to custom indexes, as only indexes in the XML schema will be retained.

For example, to add a Category 3 field to Customers, create a ARCAT3.ADB table, and extend the ARCUST.pdb table to add the new Category 3 field.

  UpgradeTable("ARCAT3.ADB", "c:\ARCategory3.xml")

  UpgradeTable("ARCUST.PDB", "c:\ARCustExtensions.xml")

See Also

Tables Functions

Book Contents

Book Index