Table_Truncate()

Examples


The Table_Truncate() function removes all records from a SQL table, leaving the table structure intact in the database.

Syntax

Table_Truncate(table table_name)

Parameters

table table_name – The name of the table from which the records are to be removed.

Return value

An integer corresponding to one of the following values:

[spacer]

Value

Description

0

The records were removed successfully.

1

There wasn’t enough memory to complete the operation.

3

Table not supported.

27

An unknown error occurred.

37

A SQL truncate command was successfully generated by Dexterity, but it was unable to be completed at the data source.

41

The operation couldn’t be completed because a user wasn’t logged into the data source.


Comments

This function performs the same function as the delete table statement that uses the delete all functionality, but performs this task differently. Table_Truncate() removes records faster than the delete table statement. However, unlike the delete table statement, it ignores any locks another user may have on records in the table.

If a user executes this function while another user has records from the named table in a client buffer, the second user will continue to see those buffered values even after the table’s records have been deleted. Should the second user save records to the table before this function is successfully completed, those records will be deleted when the command is completed. If the second user saves records to the table after the function is successfully completed, those records will be added to the table.

If the named table isn’t open when Table_Truncate() is executed, it will be opened. If the named table doesn’t exist on the current data source, this function will create it, unless Table_SetCreateMode() was used to prevent tables from being automatically created. If the table can’t be created, the error value 27 is returned from Table_Truncate().

Table_Truncate() should be used with caution since it doesn’t respect locks. It generates a SQL truncate command that is not logged in the database’s transaction log. This may cause records to reappear if the database is restored from a backup. We strongly suggest that you use the delete table statement instead of this function unless you are thoroughly familiar with the implications of issuing a SQL truncate command.



Documentation Feedback