DF_INDEX_NAME
The name of the index.
Level
Index
Supported by
The DataFlex SQL Drivers (SQL Server, DB2, and ODBC)
Type
String, permanent
Access
Read / Write
Values
Any valid index name
Syntax
Use cli.pkg
Get_Attribute DF_INDEX_NAME of {tableNumber} {indexNumber} to {StringVariable}
Remarks
In SQL databases, an index is identified by a name. Often, index names are assigned as tables are designed. In some cases, the back end will automatically create an index to enforce certain constraints. The name of indices created this way will often be the same as the constraint name.
For permanent indexes (DF_INDEX_SQL_TYPE = DF_INDEX_SERVER, DF_INDEX_CLIENT, DF_INDEX_SERVER_ONLY), this attribute can only be set inside a Structure_Start ... Structure_End operation.
For temporary indexes (DF_INDEX_SQL_TYPE = DF_INDEX_TEMPORARY), this attribute can only be set outside a Structure_Start ... Structure_End operation.
The value of this attribute is stored in the intermediate file under the keyword Index_Name.
Example
The sample procedure below shows all index names of all tables in the file list.
Procedure ShowTableIndexNames Handle hTable
Integer iLastIndex iIndex iNumSegments
String sIndex
Get_Attribute DF_FILE_LAST_INDEX_NUMBER Of hTable To iLastIndex
For iIndex From 1 To iLastIndex
Get_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To iNumSegments
If (iNumSegments > 0) Begin
Get_Attribute DF_INDEX_NAME Of hTable iIndex To sIndex
Showln " Index " iIndex ": " sIndex
End
Loop
End_Procedure
Procedure ShowIndexNames
Handle hTable
String sTable sRevision
Move 0 To hTable
Repeat
Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
If (hTable > 0) Begin
Open hTable
Get_Attribute DF_FILE_LOGICAL_NAME Of hTable To sTable
Showln "Index names for " sTable
Send ShowTableIndexNames hTable
Close hTable
End
Until (hTable = 0)
End_Procedure
Example
The procedure below creates a new table in the SQL Server Northwind database. It is used to store clock in and clock out information of employees. One index called ClockPK is created on this table.
Procedure CreateClockTable
Handle hTable hoWorkspace
String sPath sOrigFolder
Integer iColumn iIndex
//*** Make sure int file comes in first folder of datapath by
//*** making that folder current
Get phoWorkspace Of ghoApplication To hoWorkspace
Get psDataPath Of hoWorkspace To sPath
Get PathAtIndex Of hoWorkspace sPath 1 To sPath
Get_Current_Directory To sOrigFolder
Set_Directory sPath
//*** Create a SQL Server table to store clock in/out times of employees
Move 0 To hTable
Structure_Start hTable "MSSQLDRV"
Set_Attribute DF_FILE_PHYSICAL_NAME Of hTable To "Clock.int"
Set_Attribute DF_FILE_RECNUM_TABLE Of hTable To False
Set_Attribute DF_FILE_LOGIN Of hTable To "SERVER=(local);Trusted_Connection=yes;DATABASE=Northwind"
Set_Attribute DF_FILE_TABLE_NAME Of hTable To "Clock"
Set_Attribute DF_FILE_USE_DUMMY_ZERO_DATE Of hTable To True
Move 0 To iColumn
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "EmployeeID"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_BCD
Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 10
Set_Attribute DF_FIELD_NATIVE_TYPE Of hTable iColumn To SQL_INTEGER
Move 0 To iColumn
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ClockInTime"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_DATE
Move 0 To iColumn
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ClockOutTime"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_DATE
Move 0 To iIndex
Create_Index hTable At iIndex
Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To 3
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 1 To 1
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 2 To 2
Set_Attribute DF_INDEX_SEGMENT_DIRECTION Of hTable iIndex 2 To DF_DESCENDING
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 3 To 3
Set_Attribute DF_FILE_PRIMARY_INDEX Of hTable To iIndex
Set_Attribute DF_INDEX_NAME Of hTable iIndex To "ClockPK"
Structure_End hTable
//*** Reset current working folder to original value
Set_Directory sOrigFolder
//*** Add to filelist and generate fd
Move 0 To hTable
Get_Attribute DF_FILE_NEXT_EMPTY Of hTable To hTable
If (hTable > 0) Begin
Set_Attribute DF_FILE_ROOT_NAME Of hTable To "MSSQLDRV:Clock"
Set_Attribute DF_FILE_DISPLAY_NAME Of hTable To "Clock sample table"
Set_Attribute DF_FILE_LOGICAL_NAME Of hTable To "Clock"
Open hTable
Get psDDSRCPath Of hoWorkspace To sPath
Get PathAtIndex Of hoWorkspace sPath 1 To sPath
If (Right(sPath, 1) <> Sysconf(Sysconf_Dir_Separator)) ;
Move (sPath - Sysconf(Sysconf_Dir_Separator)) To sPath
Move (sPath - "Clock.fd") To sPath
Output_Aux_File DF_AUX_FILE_FD For hTable To sPath
Close hTable
End
End_Procedure