Skip to content

Get_Attribute

See Also: Database API Attributes, Set_Attribute, Creating and Modifying Table Structures in the Database Essentials section of the Developing Database Applications book, DF_FILE_PHYSICAL_NAME for examples of creating a new table.

Purpose

To retrieve a global, driver, database/connection, table, column, or index attribute.

Syntax

For table attributes:

Get_Attribute {attribute} [of {tableHandle} [{columnNum} | {indexNum} [{segmentNum}]]] ;
to {variable}

For driver attributes:

Get_Attribute {attribute} of {driverId} to {variable}

For database attributes:

Get_Attribute {attribute} of {driverId} {databaseHandle} to {variable}

Argument Explanation

  • {attribute}: Attribute Id to be retrieved.
  • {tableHandle}: Optional handle for either a table or a structure.
  • {columnNum}: Optional column to be interrogated.
  • {indexNum}: Optional index to be interrogated.
  • {segmentNum}: Number of a segment in indexNum to be interrogated.
  • {variable}: A variable to hold the value of the attribute. It should be of the same type as the attribute, if known. Otherwise, you can safely use a String variable here.
  • {driverId}: Identifier for a database driver.
  • {databaseHandle}: Identifier of a database.

What It Does

DataFlex stores information about database drivers, connections, and tables as a set of system, table, index, and column attributes. Get_Attribute allows your program to retrieve the current setting of a given attribute.

Example – Runtime Attribute

Integer iFreq
Get_Attribute DF_RUNTIME_PROGRESS_FREQUENCY to iFreq
Send Info_Box (string(iFreq) + " milliseconds") "Runtime progress frequency interval"

This example retrieves and displays the interval between runtime progress updates.

Example – Global Attribute

String sFileListName
Get_Attribute DF_FILELIST_NAME to sFileListName
Send Info_Box sFileListName "Current filelist name & path"

This example retrieves and displays the name and full path to the current filelist.

Example – Driver Attribute

Procedure ShowDriverAttribute Integer iDriver
    String sAttribValue
    Get_Attribute DF_DRIVER_CACHE_PATH of iDriver to sAttribValue
    Send Info_Box "Cache path: " sAttribValue
End_Procedure

This example retrieves and displays the driver's cache path.

Driver Ids

Drivers can be enumerated using this function:

Function DriverIndex String sDriver Returns Integer
    String sCurrentDriver
    Integer iDriver iNumDrivers
    Get_Attribute DF_NUMBER_DRIVERS to iNumDrivers
    For iDriver From 1 To iNumDrivers
        Get_Attribute DF_DRIVER_NAME of iDriver to sCurrentDriver
        If (Uppercase(sDriver) = Uppercase(sCurrentDriver)) Begin
            Function_Return iDriver
        End
    Loop
    Function_Return 0
End_Function

Example – Database Attribute

Procedure ShowDBAttribute Integer iDriver Handle hDatabase
    String sAttribValue
    Get_Attribute DF_DATABASE_LOCK_STATE of iDriver hDatabase to sAttribValue
    Send Info_Box sAttribValue "Lock SQL State(s)"
End_Procedure

This example retrieves and displays the database's lock state(s).

Database Handles

Database handles can be obtained via the DF_DATABASE_ID attribute.

Example – Table Attribute

Handle hTable
String sName
Open OrderHea
Move OrderHea.File_Number to hTable
Get_Attribute DF_FILE_ROOT_NAME of hTable to sName
Send Info_Box sName ("Root name of table " + (string(hTable)))

This example retrieves and displays the root name of the OrderHea table.

Example – Column Attribute

Integer iColumn iIndex
Handle hTable
Open Customer
Move Customer.File_Number to hTable
Move 2 to iColumn
Get_Attribute DF_FIELD_INDEX of hTable iColumn to iIndex
Send Info_Box ("Index " + (string(iIndex))) ("Main index for column " + (string(iColumn)))

This example determines the main index for column number 2 in the Customer table.

Example – Index Attribute

Integer iIndex iSegments
Handle hTable
String sTableName
Move 2 to iIndex
Open Customer
Move Customer.File_Number to hTable
Get_Attribute DF_INDEX_NUMBER_SEGMENTS of hTable iIndex to iSegments
Get_Attribute DF_FILE_DISPLAY_NAME of hTable to sTableName
Send Info_Box (string(iSegments) + " segments") ("Segments of index number " + (string(iIndex)) + " of " + sTableName + " table")

This example retrieves and displays the number of segments for index number 2 of the Customer table.

Example – Index-Segment Attribute

Integer iIndex iSegment iColumn
Handle hTable
String sFieldName sTableName
Open Customer
Move Customer.File_Number to hTable
Move 2 to iIndex
Move 1 to iSegment
Get_Attribute DF_INDEX_SEGMENT_FIELD of hTable iIndex iSegment to iColumn
Get_Attribute DF_FIELD_NAME of hTable iColumn to sFieldName
Get_Attribute DF_FILE_DISPLAY_NAME of hTable to sTableName
Send Info_Box sFieldName ("Column name in segment " + (string(iSegment)) + " of index " + (string(iIndex)) + " of table " + sTableName)

This example determines and displays the name of the column in segment 1 of index 2 of the Customer table.

Lists of Attributes