Class: cDbUpdateFunctionLibrary

See Also: Overview of the DataFlex Database Update Framework


Methods  Data Types


Hierarchy

cObject
---cDbUpdateHandler
------cDbUpdateVersion
------cDbUpdateFunctionLibrary
------cDbUpdateLogFile
------cDbUpdateUserCount
------cSQLConnectionHandler
---------cSQLConnectionIniFile
---------cDbUpdateDatabaseDriver


Library: Windows Application Class Library


Package: cDbUpdateFunctionLibrary.pkg


Description


A library with methods to make structural changes to a database.

It has high level functions built with the DataFlex database API, as well as specialized functions to make structural changes to SQL databases connected to by any of the DAW SQL drivers (MSSQLDRV, DB2_DRV & ODBC_DRV) or any of the Mertech Inc. drivers (SQL_DRV, ORA_DRV, MDSMYSQL or MDSPGSQL).


The class only contains methods, i.e. functions and procedures. No properties or events.


Note that all messages of this class has been imported to the cDbUpdateHandler class. This makes it easy to use them in the cDbUpdateVersion OnUpdate event, without the need to instantiate this class. The messages are reach through delegation in cDbUpdateVersion objects. However, the class can also be used stand-alone. See the "DbUpdateFrameworkTests.src" program for examples.


The functions are divided into three distinctive groups;

- Functions with the "SQL" prefix are all Embedded SQL functions (ESQL) and cannot be used on embedded (DataFlex) tables.

- Functions with the "API" prefix are all based on the DataFlex Structure_Start and Structure_End commands. Works fine on any table.

- Functions with the "Util" prefix are all utility functions or helper functions when dealing with databases, but not necessary to make changes to the database; as the "SQL" and "API" prefix functions are.


After the prefix the function names have keywords such as "Database", "Table", "Column" or "Index", followed by some descriptive wording on what it does. Examples; "SQLColumnRemove" or "APIColumnRename".



Note

If the class cDbUpdateFunctionLibrary is used stand-alone and not from the cDbUpdateHandler or a cDbUpdateVersion object you can use the global object handler ghoDbUpdateFunctionLibrary to call any of its functions.


Example


Procedure OnUpdate

    Boolean bOK

    Get SQLColumnAdd MyTable.File_Number "MyNewColumnName" SQL_VARCHAR 30 0 True "InitValue" to bOK

    Get SQLColumnRename MyTable.File_Number "OldColumnName" "NewColumnName" to bOK

    Get SQLColumnRemove SomeOtherdTable.File_Number "SomeColumnName" to bOK

    Get ApiTableChangeRelation MyTable.File_Number 27 2 2 to bOK

    Get ApiIndexChangeDirection MyTable.File_Number 2 2 DF_DESCENDING to bOk

End_Procedure


Example


Procedure OnClick

    Boolean bOK

    SQLIncludeScriptResource ..Scripts\CreateChinookDatabase.sql as CreateChinookDatabase.sql    

    Get SqlUtilExecuteResource of ghoDbUpdateFunctionLibrary "CreateChinookDatabase.sql" MSSQLDRV_ID True to bOK

End_Procedure


Next Topic


cDbUpdateLogFile