f2s_column_override_value

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

Syntax

set_attribute f2s_column_override_value of {FileNumber} {FieldNumber} to {variable}
get_attribute f2s_column_override_value of {FileNumber} {FieldNumber} to {variable}

Parameter

Description

FileNumber

Number of the file (filename.File_Number)

FieldNumber

Number of the column (based on order in FD file)

variable

Variant Value. Contains the value that will be used as a default or find constraint.

Description

This attribute is somewhat like a default in that the value will be used during record creation if a value is not given for the specified column. Unlike a default, this value is also used alongside the f2s_table_override_state attribute to constrain find operations as well. This gives an easy way for an application to be converted to a multi-company setup without requiring extensive code changes (as these settings are global unlike DD defaults for instance).

Note

If f2s_table_constraint is used on the table, then f2s_table_override_state and f2s_column_override_value’s won’t be used for find operations. You must remember to manually add your constraints if they apply.

Example

In this example, the field Company has been added to the Customer table. For all of the records, the Company value has been set to “Some Company”. When f2s_column_override value is set to “Another Company”, the new record created will have the Company field set with “Another Company”. When f2s_table_override_state is false (default), all the records in the table are returned during a find. Later when the f2s_table_override_state is set to true, only that record is returned in the find.

Open customer
Field_Map CUSTOMER.File_Number "Company" to FieldNum

//Set the default for the Company name
Set_Attribute f2s_column_override_value of CUSTOMER.File_Number FieldNum to "Another Company"
Clear CUSTOMER
Move "Carols Coffee" to Customer.Name
Move "1 Cafe Lane" to CUSTOMER.Address
Move "Latte City" to CUSTOMER.CITY
Move "MN" to CUSTOMER.STATE
Move '56512' to CUSTOMER.ZIP
Move "New Customer" to CUSTOMER.COMMENTS
SaveRecord CUSTOMER

//do a find
Get_Attribute f2s_table_override_state of CUSTOMER.File_Number to bOverRide
Showln (SFormat("Override is %1", bOverRide))
Clear CUSTOMER
Find ge CUSTOMER by Index.1
While (Found)
    Showln (SFormat("Customer:  %1; Company: %2", Trim(CUSTOMER.NAME), Trim(CUSTOMER.Company)))
    Find gt CUSTOMER by Index.1
Loop

//toggle the override state
Set_Attribute f2s_table_override_state of CUSTOMER.File_Number to (1-bOverRide)
Get_Attribute f2s_table_override_state of CUSTOMER.File_Number to bOverRide
Showln (SFormat("Override is %1", bOverRide))
//do a find
Clear CUSTOMER
Find ge CUSTOMER by Index.1
While (Found)
    Showln (SFormat("Customer:  %1; Company: %2", Trim(CUSTOMER.NAME), Trim(CUSTOMER.Company)))
    Find gt CUSTOMER by Index.1
Loop

When run, this example produces:

Override is 0
Customer:  Carols Coffee; Company: Another Company
Customer:  Access Miles; Company: Some Company
Customer:  American Products, Inc.; Company: Some Company
    **** Rest of the data in the table ****
Override is 1
Customer:  Carols Coffee; Company: Another Company

Replaces

DF_FIELD_PROGRAMMATIC_DEFAULT