Skip to content

DF_SQL_RELATION_COLUMN

The name of the column the relation relates from.

Level

Table relation

Supported by

The DataFlex SQL Drivers (SQL Server, DB2, and ODBC)

Type

String, permanent

Access

Read Only

Values

Column name

Syntax

Use cli.pkg
Get_Attribute DF_SQL_RELATION_COLUMN of {tableNumber} {relationNumber} to {StringVariable}

Remarks

When a table is opened, the foreign key information is retrieved from the back end. This information can be used to examine the relationships as they are defined on the back end. The SQL relation attributes can be accessed via the Get_Attribute command in the same way as field attributes.

Example

Procedure ShowSQLRelations Handle hTable
    Integer iNumRelations
    Integer iFKColumn
    String sFkTable
    String sFKSchema
    String sFKColumn
    String sPKSchema
    String sPKTable
    String sPKColumn
    Integer iCurRel

    Move 0 To hTable
    Repeat
        Get_Attribute DF_FILE_NEXT_OPENED Of hTable To hTable
        If (hTable <> 0) Begin
            Get_Attribute DF_FILE_NUMBER_SQL_RELATIONS Of hTable To iNumRelations
            If (iNumRelations > 0) Begin
                Get_Attribute DF_FILE_TABLE_NAME Of hTable To sFKTable
                Get_Attribute DF_FILE_OWNER Of hTable To sFKSchema
                For iCurRel From 1 To iNumRelations
                    Get_Attribute DF_SQL_RELATION_COLUMN Of hTable iCurRel To iFKColumn
                    Get_Attribute DF_SQL_RELATION_RELATED_SCHEMA Of hTable iCurRel To sPKSchema
                    Get_Attribute DF_SQL_RELATION_RELATED_TABLE Of hTable iCurRel To sPKTable
                    Get_Attribute DF_SQL_RELATION_RELATED_COLUMN Of hTable iCurRel To sPKColumn
                    Get_Attribute DF_FIELD_SQL_NAME Of hTable iFKColumn To sFKColumn
                    Showln sFKSchema "." sFKTable "." sFKColumn " relates to " sPKSchema "." sPKTable "." sPKColumn
                Loop
            End
        End
    Until (hTable = 0)
End_Procedure

The sample procedure above shows all columns that are part of a foreign key of the given table.