ApiTableConvertToSQL_Ex - cDbUpdateFunctionLibrary

 To convert a table from the current workspace (Filelist.cfg) to an SQL database back-end. The target is the database that has been set as the "enabled" connection with the SQLConnections tool or with the DataFlex "SQL Connection Manager" program if DataFlex 19.0 or later.


Type: Function


Parameters: Handle hTable String sDriverID Boolean bUseConnectionID Boolean bToAnsi Boolean bRecnum Boolean bCopyData

Parameter

Description

hTable

A file handle to the table name. Same as the Filelist.cfg slot number.

sDriverID

The database driver ID

bUseConnectionID

If the .int file should use a connection ID

bToAnsi

If the SQL table should use ANSI format

bRecnum

If the table should be converted as a recnum table

bCopyData

If all data from the embedded table should be copied to the newly created SQL table


Syntax


Function ApiTableConvertToSQL_Ex Handle hTable String sDriverID Boolean bUseConnectionID Boolean bToAnsi Boolean bRecnum Boolean bCopyData

Call:

Get ApiTableConvertToSQL_Ex OrdHea.File_Number MSSQLDRV_ID True True True True to bOK



Description

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

Note: You must have setup a SQL connection for the workspace with the help of the Database Update Framework's SQLConnections tool. Or have setup a Maintained connection, if using DataFlex 19 or later. Important to note is that if you have setup an SQL connection with a maintained connection and you are using another SQL back-end then Microsoft SQL Server you must setup additional properties in the cDbUpdateVersion object, or by also creating an SQL connection record with the SQLConnection tool.


There is a variant of this function where you - instead of passing a series of parameters you set a series of properties. See: ApiTableConvertToSQL

Important: If the table exist on the SQL back-end but the Filelist entry doesn't have a driver ID prefix - the Filelist entry will be adjusted to point to the SQL table. So the Filelist RootName will be adjusted with a driver prefix. E.g. "Customer" will be changed to "MSSQLDRV:Customer".

It will not convert an embedded table to SQL that already exists on the SQL back-end. You need then instead use the ApiTableAttachToSQL function. The reason for this is that the framework is re-entrance enabled - meaning that it should be able to run the same code twice by resetting the pnVersionNumber value without bringing mayhem to the SQL database.


Example 1


// This sample is for a Microsoft SQL Server

Object oDbUpdateVersion1 is a cDbUpdateVersion

    Set pnVersionNumber to 1.0


    Procedure OnUpdate

        Boolean bOK

        Get ApiTableConvertToSQL_Ex Customer.File_Number MSSQLDRV_ID True True True True to bOK

    End_Procedure


End_Object



Example 2


// This sample is for an IBM DB2 database

Object oDbUpdateVersion1_1 is a cDbUpdateVersion

    Set pnVersionNumber to 1.1

    Set psBaseTableSpace to "USERINFO1"

    Set psIndexTableSpace to "USERINFO1"

    Set psLongTableSpace to "USERINFO1"

    Set psSchema to "DBO"

   

    Procedure OnUpdate

        Boolean bOK

        Get ApiTableConvertToSQL_Ex OrdHea.File_Number DB2_DRV_ID True True True True to bOK

    End_Procedure


End_Object