f2s_buffered_save

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

Syntax

f2s_buffered_save {FileName}

Parameter

Description

FileName

Name of the file.

Description

This command is used to send a record to the “Save Record” buffer. The records will then be submitted to SQL in a batch rather than one at a time. It must be used along with f2s_begin_buffered_save and f2s_end_buffered_save. Each time a record is created, this command should be called to insert it into the buffer.

Using this set of commands can be useful to efficiently save a large number of records. Once the buffer is full, the save occurs automatically and the buffer will be emptied out.

It is good practice to use this method inside of a transaction to maintain atomicity.

Example

SQL Server Code to create a buffer of 100 records each to save into a Table.
Integer iCount
Open "SALESPERSON.int" as SALESPERSON
BEGIN_TRANSACTION
    //Set the MAX_ROWS to 100
    f2s_begin_buffered_save SALESPERSON.File_Number MAX_ROWS 100

    //The 1,000 records will be recorded in blocks of 100 records each (10% of the total).
    For iCount from 1 to 1000
        Move iCount to SALESPERSON.ID
        Move ("Name" + Trim(iCount)) to SALESPERSON.NAME
        f2s_buffered_save SALESPERSON.File_Number
        Showln 'Saving Record: ' iCount
    Loop
    f2s_end_buffered_save SALESPERSON.File_Number
END_TRANSACTION
Showln 'Finished ...'
Inkey PageEnd

Related Commands

Replaces: Command SQL_SAVE_BUFFER