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
To retrieve a global, driver, database/connection, table, column, or index attribute.
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}
{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.
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.
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.
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.
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.
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 iDrive
End
Loop
Function_Return 0
End_Function
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 can be obtained via the DF_DATABASE_ID 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 rootname of the OrderHea table.
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.
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.
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.