Skip to content

DF_FILE_OWNER

See Also: Get_Attribute, Set_Attribute

The owner of the table.

Level

Table

Supported by

All Drivers

Type

String, permanent

Access

Read / Write

Values

Any valid owner string.

Remarks

The owner of the table. If there is no owner of the table, the string is empty.

The Embedded Database does not support table owners and will always return an empty string. Trying to set the attribute will generate a DFERR_UNSUPPORTED_ATTRIBUTE error.

The DataFlex Pervasive.SQL Driver supports table owners. A Pervasive.SQL owner name puts a password on a table. Owner names have an additional attribute:

Owner Attribute Meaning
READONLY The Pervasive.SQL engine will allow opening the table without owner name for read-only access.
ENCRYPT The Pervasive.SQL engine will encrypt the data in the data table. The owner name must be specified when opening the table.

You can use the attribute to get the owner name. Setting the owner name must be done via the DFBTR_Set_Owner command. This command allows you to specify the owner name attribute next to the owner name itself. Owner names are stored in the intermediate file using the Owner keyword.

The DataFlex SQL Driver supports owner names. They will project the DF_FILE_OWNER attribute on the schema, or in the case of SQL Server, the owner of the table. You can set this attribute both inside and outside a Structure_Start ... Structure_End operation. If set outside of a structure operation, all open cursors for the table will be closed. Owner names are stored in the intermediate file using the Schema_Name keyword.

Example Procedures

ShowOwner

Procedure ShowOwner
    Handle hTable
    String sTable sOwner
    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
            Get_Attribute DF_FILE_OWNER Of hTable To sOwner
            Showln sTable " -- " sOwner
            Close hTable
        End
    Until (hTable = 0)
End_Procedure // ShowOwner

The sample procedure above opens all tables in the file list and shows the table and owner name for every table.

ChangeOwner

Procedure ChangeOwner String sOldOwner String sNewOwner
    Handle hTable
    String sOwner
    Move 0 To hTable
    Repeat
        Get_Attribute DF_FILE_NEXT_OPENED Of hTable To hTable
        If (hTable > 0) Begin
            Get_Attribute DF_FILE_OWNER Of hTable To sOwner
            If (sOwner = sOldOwner) ;
                Set_Attribute DF_FILE_OWNER Of hTable To sNewOwner
        End
    Until (hTable = 0)
End_Procedure // ChangeOwner

The sample procedure above changes the owner for every open table that has a given owner name. Note that this procedure will only work for a table accessed through a SQL Database Driver.