Skip to content

Delete_Field

See Also: Create_Field, Structure_Start

Purpose

To delete a column from the structure of a database table.

Syntax

Delete_Field {table-handle} {column-num}

Where:

  • {table-handle} is a handle to the database table.
  • {column-num} is the number of the column to delete.

What It Does

This command will delete the column {column-num} from the table {table-handle}.

Example

Procedure DeleteColumn String sTableName Integer iColumnNo
    Handle hTable
    // Open database table
    Open sTableName As hTable
    // Start of the structure operation.
    // The DataFlex driver name is "DATAFLEX".
    Structure_Start hTable "DATAFLEX"
    // Specify the column to delete
    Delete_Field hTable iColumnNo
    Structure_End hTable DF_STRUCTEND_OPT_NONE
End_Procedure

Notes

  • This command must be used within a Structure_Start ... Structure_End block. If not, you will get an error message.

  • Because DataFlex maintains relationships based on column numbers, an invalid relationship may result when a column is deleted. For example, if column 3 is deleted from the parent table, and a child column relates to it, the relationship will now be pointing to a different column.

  • The Structure_End command that terminates the structural changes of the database table will automatically reindex the table, if necessary.

  • You can use the Table Editor in the Studio to create your tables instead of doing it programmatically.