f2s_table_sql_name

Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

set_attribute f2s_table_sql_name of {FileNumber} to {variable}
get_attribute f2s_table_sql_name of {FileNumber} to {variable}

Parameter

Description

FileNumber

Number of the file (filename.File_Number) If a table is being created (set_attribute) this should either be 0 or an unused filenumber in the FileList

variable

String variable. The name of the table cooresponding to that FileNumber

Description

Getting the attribute returns the name of the SQL table cooresponding to the specified file number. This will throw an error if the file is not open. Setting the attribute is used to name a table being created or change which table a filelist entry points. This attribute must be set within a structure start/structure end block. It cannot be used to rename a existing table on the SQL server.

This attribute cooresponds to the DATABASE_NAME field in the table’s INT file.

Examples

get_attribute

//get the name of file 25 in the FileList
//this assumes table 25 is open.  If it is not, this will throw an error

string sTable
get_attribute f2s_table_sql_name of 25 to sTable

//in the OrderEntry example, sTable should be Customer

set_attribute

The code below uses the Order Entry Example. The table NewCust is identical in structure to Customer, but has different data. In the procedure, the filelist entry for Customer will be repointed to NewCust. See Structure_Start and Structure_End in the DataFlex documentation for more information.

Procedure RepointCustomerToNewCust
   Handle hTable hOpenTable
   String sOldFirstCust sNewFirstCust

   Send Clear to oCustomer_DD
   Send Find to oCustomer_DD GE Index.1
   If (Found) Begin
       Move (Trim(Customer.Name)) to sOldFirstCust
   End
   Send Clear to oCustomer_DD

   Move Customer.File_Number to hTable
   Move Customer.File_Number to hOpenTable

   Structure_Start hTable _f2s_ActiveDriver
       Set_Attribute f2s_table_sql_name of hTable to "NewCust"
   Structure_End hTable

   Open hOpenTable

   Send Clear to oCustomer_DD
   Send Find to oCustomer_DD GE Index.1
   If (Found) Begin
       Move (Trim(Customer.Name)) to sNewFirstCust
   End
   Send Clear to oCustomer_DD
   showln  (sFormat("The old first customer was %1 but now is %2.", sOldFirstCust, sNewFirstCust))

End_Procedure

Before the procedure is run, the customer.int file begins:

DRIVER_NAME f2s_ms
DATABASE_NAME Customer

After the procedure is run the customer.int file begins:

DRIVER_NAME f2s_ms
DATABASE_NAME NewCust

Replaces: DF_FILE_TABLE_NAME