Skip to content

DF_NUMBER_DRIVERS

See Also: Get_Attribute, Set_Attribute

The number of currently loaded database drivers.

Level

Global

Type

Integer, temporary

Access

Read Only

Values

Positive Integers

Remarks

DF_NUMBER_DRIVERS returns the number of database drivers that are currently loaded. It can be used to enumerate the currently loaded drivers or to determine the index of a specific loaded driver. The index of a specific loaded driver is needed for driver-level attributes.

The driver number is not a constant; it is the index of the loaded driver, so you will need to get it once you have loaded the driver.

Example: Show Driver List

Procedure ShowDriverList
    Integer iNumDrivers
    String sDriver
    Integer iDriver

    Get_Attribute DF_NUMBER_DRIVERS To iNumDrivers
    For iDriver From 1 To iNumDrivers
        Get_Attribute DF_DRIVER_NAME of iDriver to sDriver
        Showln "Driver: " sDriver
    Loop

    Showln
    Showln "Done..."
End_Procedure // ShowDriverList

This example enumerates all loaded drivers and lists them.

Example: Driver Index

Function DriverIndex String sDriver Returns Integer
    String sCurrentDriver
    Integer iNumberOfDrivers
    Integer iDriver
    Integer iCount

    Move 0 To iDriver
    Get_Attribute DF_NUMBER_DRIVERS To iNumberOfDrivers
    For iCount From 1 To iNumberOfDrivers
        Get_Attribute DF_DRIVER_NAME Of iCount To sCurrentDriver
        If (Uppercase(sCurrentDriver)) = (Uppercase(sDriver)) ;
            Move iCount To iDriver
        Loop
    Function_Return iDriver
End_Function // DriverIndex

The sample function above returns the index for a specific loaded driver.