SQLTableCreate - cDbUpdateFunctionLibrary

Creates an SQL Table at the SQL end by a filelist number. The function was created for completeness because there is also the ApiTableCreate function which is actually the preferred method as it is easier to use.


Type: Function


Parameters: String sTableName

Parameter

Description

hTable

A file handle to the table name. Same as the Filelist.cfg slot number. Note: There is also a SqlTableCreateByTableName function where you instead of the filelist number pass the table name as a string.


Syntax


Function SQLTableCreate Integer hTable

Call:

Get SQLTableCreate SysTable.File_Number to bOK



Description

Use it to create a new SQL table. The file handle is the same as the file number in Filelist.cfg.

Note: The function will create a new SQL table with a dummy column named "dummy". This is because SQL databases doesn't like tables with no columns in them. It is the programmers responsibility to remove the dummy column after other columns has been added. It will also create a filelist slot and the .int file. If you want to remove a table from the DataFlex Embedded database, use the API based ApiTableRemove function.


Example


Procedure OnUpdate

    Boolean bOK

   

    Get SQLTableCreate MyTable.File_Number to bOK

    Get SQLColumnAdd MyTable.File_Number "NewColumnAscii1"   DF_ASCII_DUF 34 0 False "" to bOK

    Get SQLColumnAdd MyTable.File_Number "NewColumnNumeric2" DF_BCD_DUF    8 4 False "" to bOK

    Get SQLColumnAdd MyTable.File_Number "NewColumnDate3"    DF_DATE_DUF  34 0 False "" to bOK


    // Don't forget to remove the temporary "dummy" column created by "SQLTableCreate".

    Get SqlColumnRemove MyTable.File_Number "dummy" to bOK

End_Procedure