TSL_FlushAll function

The TSL_FlushAll function flushes data for all containers to disk in a single transaction.

Syntax

TSL_FlushAll(
           handle      lvarchar,
           writeflag   integer DEFAULT 1)
returns integer 
handle
The table and column name combination that is returned by the TSL_Attach or the TSL_Init function.
writeflag (Optional)
An integer that is the sum of flag values that represent whether duplicate elements are allowed for irregular time series and whether logging is reduced. You must supply a value for the duplicate element behavior (1 or 5). Possible values are: 1, 5, 257 (1 + 256), 261 (5 + 256).
1 = Default. Duplicate elements are allowed. Cannot be combined with the value 5.
5 = Duplicate elements replace existing elements. Cannot be combined with the value 1.
256 = Logging is reduced. See the description of the TSOPEN_REDUCED_LOG flag in The flags argument values.

Usage

Use the TSL_FlushAll function to write time series data to disk as part of a loader program. You must run the TSL_FlushAll function in a transaction in the context of a loader session that was initialized by the TSL_Init function. You run the TSL_FlushAll function to save data that is loaded by the TSL_Put, TSL_PutSQL, or TSL_PutRow function.

If you specify that duplicate elements are allowed for irregular time series with the writeflag argument value of 1, the TSL_FlushAll function inserts data in the same way as the PutElem function. You can specify that duplicate elements replace existing elements that have the same timestamps with the writeflag argument value of 5 so that the TSL_FlushAll function inserts data in the same way as the PutElemNoDups function.

If you specify reduced logging with the writeflag argument, you must run TSL_FlushAll function in a transaction that can include only other functions that use reduced logging with the TSOPEN_REDUCED_LOG flag. The elements that are saved are not visible by dirty reads until after the transaction commits.

The TSL_FlushInfo function returns eight categories of information about the last flush operation that saved data to disk.

Returns

An integer that indicates the status of the function:

  • A positive integer = The number of elements that were inserted.
  • -1 = Process was interrupted or encountered a severe error.

Example: Run the TSL_FlushAll function

The following statement saves the data to disk for the table ts_data and the TimeSeries column raw_reads:

BEGIN WORK;
EXECUTE FUNCTION TSL_FlushAll('ts_data|raw_reads');
COMMIT WORK;

Example: Run the TSL_FlushAll function with reduced logging

The following statement saves the data to disk with reduced logging:

BEGIN WORK;
EXECUTE FUNCTION TSL_FlushAll('ts_data|raw_reads', 257);
COMMIT WORK;

Example: Run the TSL_FlushAll function with reduced logging and no duplicate elements

The following statement saves the data to disk with reduced logging and replaces existing elements that have the same timestamps as new elements:

BEGIN WORK;
EXECUTE FUNCTION TSL_FlushAll('ts_data|raw_reads', 261);
COMMIT WORK;