ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Managing automatic identifiers
  • Writing deleted or crossed records
  • Version of the data file after a write operation
  • Managing binary memos
  • If you use <Source>.Write with a Hyper File 5.5 database
  • Browsing and writing a record
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
<Source>.Write (Function)
In french: <Source>.Ecrit
ODBCNot available with this kind of connection
Writes a record into a data file without updating the indexes corresponding to all keys used in the data file. The memos are added if necessary (if the management of memos is enabled, <Source>.SetMemo).
After the call to <Source>.Write:
  • integrity and duplicate errors are not checked.
  • if a lock problem occurs (attempt to modify a locked record), HErrorLock returns True and the record is not modified.
  • the number of the current record is modified: the current record corresponds to the record written.
Remarks:
  • To update the indexes during a write operation, use <Source>.Add or <Source>.Modify.
    OLE DBNative Connectors (Native Accesses) <Source>.Write and <Source>.Modify are equivalent. The indexes on the database are updated.
  • If a key value is modified with <Source>.Write, the index will no longer be consistent. It must be re-indexed (<Source>.Index).
  • This function can be used to write a record into a selection performed by a query (query run with the hWithFilter constant).
Example
// Write a record at the end of a data file
Customer.Write(HNbRec() + 1)
Syntax
<Result> = <Source>.Write([<Record number> [, <Options>]])
<Result>: Boolean
  • True if the writing was performed in the data file,
  • False if an error occurred (lock, ...): the record is not modified. HError is used to identify the error.
<Source>: Type corresponding to the specified source
Name of the data file used.
<Record number>: Optional integer
Number of the record to write. The record loaded in memory is re-written on the specified record.
If this number is greater than the total number of records in the data file, intermediate deleted records will be created in order for the sequential reading of the data file (<Source>.Read) to be consistent.
If this parameter is not specified (equal to 0 or to the hCurrentRecNum constant), <Source>.Write modifies the current record in the data file.
OLE DBNative Connectors (Native Accesses) <Source>.Write modifies the current record only. You cannot specify a record number other than the current one (to specify the current record number, use the hRecNumCurrent constant).
<Options>: Combination of optional constants
Configures:
  • the mode for calculating the automatic identifier: For more details on automatic identifiers for new records, see Managing the automatic identifier during an addition.
    hForceIDAutoThe automatic identifier is not calculated during the write operation: The value of the identifier is the one stored during the write operation.
    hRecalculateIDAutoThe automatic identifier of the record will be re-calculated during the write operation. This constant has priority over hForceIDAuto and hSetIDAuto.
    hSetIDAutoThe automatic identifier is not calculated during the write operation: The value of the identifier is the one stored during the write operation.
    The next value of the identifier calculated by the HFSQL engine will correspond to the greatest value of the identifier in the file +1.
    hWriteDefault
    (Default value)
    If the written record is not a deleted record, the automatic identifier (if it exists) of the record in the data file is re-used.
    If the written record is a deleted record, a new automatic identifier is calculated for the record.
    The hWriteDefault constant is ignored if hWriteDefault is specified with one of the other constants.

    A WLanguage error is generated if the three constants (hForceIDAuto, hSetIDAuto and hRecalculateIDAuto) are used at the same time.
  • the lock mode applied to the record.
    If no lock constant is specified, the record is not locked.
    hLockNo
    (Default value)
    No lock: the written record is not locked.
    hLockReadWriteLock in read/write mode: the written record will be locked in read/write. This record cannot be read or modified by another application. Only the current application can modify it, read it or unlock it.
    hLockWriteLock in write mode: the written record will be locked in write mode. This record can be read by another application but it cannot be modified by another application. Only the current application can modify it or unlock it.

OLE DBNative Connectors (Native Accesses) Lock options will have no effect if the OLE DB provider or Native Connector (also called Native Access) does not support locks.

Hyper File 5.5 <Options> is ignored.
Remarks

Managing automatic identifiers

By default, the "automatic identifier" item is automatically updated when a record is added into a data file.
The hForceIDAuto and hSetIDAuto constants are used to modify the default behavior of the automatic identifier.
For more details on automatic identifiers for new records, see Managing the automatic identifier.

OLE DBNative Connectors (Native Accesses) Special cases
  • If the database generates an automatic identifier, the HFSQL engine keeps this value. If the hForceIDAuto or hSetIDAuto constant is specified, the HFSQL engine replaces the generated value by the desired value.
    Remark: the hForceIDAuto constant is equivalent to hSetIDAuto: the automatic identifier calculated by the HFSQL engine during the next addition will be unique in the data file.
  • If no automatic identifier is generated by the database, the HFSQL engine generates the value and assigns it to the automatic identifier.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadExternal languageAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5

Writing deleted or crossed records

If the record number corresponds to a crossed record or to a deleted record, this record is re-enabled.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadExternal languageAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5

Version of the data file after a write operation

If the record was written (no lock problem, etc.), the data file version number is modified. To get the version number, use <Source>.Version.

Managing binary memos

When a record is modified, the memos are modified if necessary (if the management of memos is enabled by <Source>.SetMemo).
Reminder: to initialize a binary memo item, use <Source>.LinkMemo.
WINDEVWEBDEV - Server codeExternal languageAjaxHyper File 5.5

If you use <Source>.Write with a Hyper File 5.5 database

The TEXT items are automatically filled with space characters.
WINDEVWEBDEV - Server codeNative Connectors (Native Accesses)

Browsing and writing a record

If the write operation is performed during a browse, the record written will be visible in the current browse only. If other browse operations have been defined on this database, the record written will only be visible once these browse operations have been re-initialized.
Component: wd300hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/06/2023

Send a report | Local help