f2s_record_count_state

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

Syntax

set_attribute f2s_record_count_state of {DriverID} to {variable}
get_attribute f2s_record_count_state of {DriverId} to {variable}

Parameter

Description

DriverID

The ID of the driver for which this applies. In most cases, you should use _f2s_ActiveDriverID.

variable

Integer variable. Three states. 0=block record counting. >0 Fixed value for DF_FILE_RECORDS_USED. <0 turn record counting on. The default value is -1

Description

The dataflex read only attribute DF_FILE_RECORDS_USED, is the number of records in a particular table. To get this using an SQL server, a select Count(*) query must be run. This is an expensive process. Setting f2s_record_count_state to a value greater than 0 sets DF_FILE_RECORDS_USED to a particular number and surpresses the call for select Count(*). Setting the attribute to 0, turns off record counting (no select Count(*) call is made). Setting the attribute to less than 0 turns record counting on (select Count(*) call is made).

Getting this attribute gets the attribute’s value.

When to Use

Sometimes when record counts in a table are used, an exact number is not needed. Updating this count occassionally works just as well. This is when setting f2s_record_count_state to a value of 0 or greater is useful. It can speed up the program by reducing the number of calls to the server with an expensive query.

Examples

get_attribute

integer iRecordCount

get_attribute f2s_record_count_state to iRecordCount

set_attribute

Integer iCustomerCount iValue

//this will go to the server and get the actual count - let's say its 100
Get_Attribute DF_FILE_RECORDS_USED of  Customer.File_Number to iCustomerCount

Showln (SFormat("The number of customer records is %1",iCustomerCount))

//now, we will set the attribute to a number, 101
Set_Attribute f2s_record_count_state of _f2s_ActiveDriverId to 101

//iValue=101
Get_Attribute f2s_record_count_state of _f2s_ActiveDriverId to iValue

//iCustomerCount=101
Get_Attribute DF_FILE_RECORDS_USED of  Customer.File_Number to iCustomerCount

Showln (SFormat("The new values are: %1 / %2",iValue, iCustomerCount))

Replaces: Commands SET_FIXED_FILE_RECORDS_USED, GET_FIXED_FILE_RECORDS_USED, SUPPRESS_SELECT_COUNT and UNSUPPRESS_COUNT