You are here:
Temp Table Contract
Temp tables are like database tables, they exist on the database but have no counterpart on the backend and are never synced back. The temp tables support the same features as the regular tables, for example, indexes.
Required Editions
| Available in: Enterprise, Performance, and Unlimited Editions |
Use a contract to define specific columns and indexes to store in temp tables. Avoid using temp tables for data that needs to be written or recalculated often.
When you launch the offline mobile app, the defined temp tables are created and when the app is terminated, the temp tables are lost. The temp tables and the data stored in them are retained until the CG Cloud offline mobile app or the simulator app is open. Temp tables read and write faster than the other tables, and to provide high performance for the data that's read frequently and written infrequently.
For example, the temp table stores data such as a result of a database operation or a merge engine calculation.
The table describes the attributes of the TempTable root node.
| Attribute | Description | Value/Pattern | Required |
|---|---|---|---|
| name | Specifies the unique name of the temp table. The name contains a _T suffix. For example: TmpOrderItemMergeResult_T. | String | Yes |
| schemaVersion | Specifies the version of the design contract. | String | No |
The TempTable root contains the columns and indexes elements. Use the sub elements to define a list of table columns and indexes. The columns element contains the column sub element that you can use to describe a single database column. Always define at least one column.
| Attribute | Description | Value/Pattern | Required |
|---|---|---|---|
| name | Specifies the unique name of the database column. | String | Yes |
| domain | Specifies the data type of the column. | String | No |
| defaultValue | Specifies the default value of the defined column. | String | No |
| nullable | If True, the database is allowed to write null values to this column. Only the PKey column is not nullable. | Number | No |
| migrationDefault | If a new column is introduced, this value is used to update the existing records; otherwise the value of the new column is null. | Boolean | Yes |
The TempTable contract definition can contain one or more Index definitions. Each index must have a name attribute, and should reference at least one column on this table. Use these attributes to define the columns to be indexed.
| Attribute | Description | Value/Pattern | Required |
|---|---|---|---|
| name | Specifies the unique name of the index on the database. | String | Yes |
| column | Specifies the name of the column to use for the index. | String | Yes |
Sample XML code:
<TempTable name="TmpOrderItemMergeResult_T" schemaVersion="">
<columns>
<column name="PrdMainPKey" defaultValue="" nullable="true" domain="DomPKey" migrationDefault=" " />
<column name="Listed" defaultValue="0" nullable="true" domain="DomBool" migrationDefault=" " />
<column name="FocusProductType" defaultValue="' '" nullable="true" domain="DomPrdFocusProductType" migrationDefault=" " />
<column name="MaxValue" defaultValue="" nullable="true" domain="DomDecimal" migrationDefault=" " />
<column name="IsDeleted" defaultValue="" nullable="true" domain="DomBool" migrationDefault="0" />
</columns>
<indexes>
<index name="BpaAddress_UK_BpaAddress" >
<column name="PKey" />
</index>
<index name="">
<column name="" />
</index>
</indexes>
</TempTable>

