|
|
|
|
|
- Managing automatic identifiers
- Reusing the deleted or freed records
- Version of data file after an addition
- Adding a record into a query
- Adding records into a view
- Browsing and adding records
- Slowness when adding or deleting a record for the first time in an HFSQL data file
- Addition into a database in Hyper File 5.5 format
<Source>.Add (Function) In french: <Source>.Ajoute
Not available with this kind of connection
Adds: - the record found in memory into the data file (query or view).
- the record found in a Record variable into the data file (query or view).
The indexes corresponding to all the keys used in the data file are automatically updated. The possible memos are added if the management of memos is enabled ( <Source>.SetMemo). After the call to <Source>.Add: - An automatic management of errors is proposed for several types of errors: Duplicate error, integrity error, password error, modification conflict error and status error during modification conflict, lock error, ... For more details, see Assisted HFSQL error handling.
- If the management of duplicates is enabled and if the data file contains a unique key, HErrorDuplicates returns True if the value of added key is not unique. The record is not added.
- The added record becomes the current record. The automatic identifier is automatically filled. By default, the current iteration is not affected.
Remark: The entire record in memory is written into the data file with the values that were assigned to it (otherwise, the content of record previously read). To clear the values from the record in memory, all you have to do is use <Source>.Reset.
// Add a record in a data file // (record described through programming) Customer.LastName = "Clark" Customer.FirstName = "Vince" Customer.Address = "Palm Lane" Customer.City = "Philadelphia" Customer.Zip = "19101" Customer.Country = "USA" Customer.Add()
Syntax
Adding the record found in memory into a data file, view or query Hide the details
<Result> = <Source>.Add([<Options>])
<Result>: Boolean - True if the record was added,
- False if a problem occurred (integrity error, duplicate error, ...). HError is used to identify the error.
<Source>: Type corresponding to the specified source Name of the data file, view or query used. <Options>: Optional constant Used to configure:- the effect of addition on the current browse.
- the mode for calculating the automatic identifier. For more details, see Managing the automatic identifier during an addition.
- the lock mode applied to the added record.
- Management of locks not available in PHP.
- Management of locks not available in SQLite databases.
- Access by JDBC: The management of locks is not available for databases accessed by JDBC.
- the management of duplicates.
- the management of integrity.
| | hAffectBrowse | Effect of addition on the browse: The addition affects the browse. For example, <Source>.ReadNext used after <Source>.Add positions on the record found after the added record. The hAffectBrowse constant has priority over the hWriteDefault constant. | hCheckDuplicates | Management mode of duplicates: Checks for duplicates for this operation, even if the duplicate check is disabled (<Source>.SetDuplicates). A WLanguage error occurs if the hIgnoreDuplicates and hCheckDuplicates constants are used at the same time.
| hCheckIntegrity | Management mode of integrity: Checks the integrity of operation even if the automatic integrity check is disabled (<Connection variable>.SetIntegrity). A WLanguage error occurs if the hIgnoreIntegrity and hCheckIntegrity constants are used at the same time.
| hForceIdAuto | Mode for calculating the automatic identifier: The automatic identifier is not calculated during the addition. The identifier corresponds to:- the value assigned to the item through programming (CUSTOMERID = 7 for example)
- the default identifier value specified in the data model editor (if the data file was just opened, with no record read)
- the identifier value found in memory (identifier value for the last record read in the data file).
Once the record is added, the next automatic identifier calculated by the HFSQL engine will be calculated while ignoring the value added by hForceIdAuto. A WLanguage error occurs if the hSetIdAuto and hForceIdAuto constants are used at the same time. | hIgnoreDuplicates | Management mode of duplicates: Does not check for duplicates for this action, even if the automatic duplicate check is enabled (<Source>.SetDuplicates). A WLanguage error occurs if the hIgnoreDuplicates and hCheckDuplicates constants are used at the same time.
| hIgnoreIntegrity | Management mode of integrity: Ignores the integrity check for this add operation, even if the automatic integrity check is enabled (<Connection variable>.SetIntegrity). A WLanguage error occurs if the hIgnoreIntegrity and hCheckIntegrity constants are used at the same time.
| hLockNo (default value) | Lock mode applied to the added record: No lock: the added record will not be locked.
| hLockReadWrite | Lock mode applied to the added record: Lock in read/write mode: the added 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.
This constant is available for HFSQL Client/Server and Native Connectors only. | hLockWrite | Lock mode applied to the added record: Lock in write mode: the added 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.
This constant is available for HFSQL Client/Server and Native Connectors only. | hSetIdAuto | Mode for calculating the automatic identifier: The automatic identifier is not calculated during the addition: the identifier value will be the one stored during the addition. The next identifier value calculated by the HFSQL engine will correspond to the greatest identifier value in the file +1. A WLanguage error occurs if the hSetIdAuto and hForceIdAuto constants are used at the same time. | hWriteDefault (default value) | Effect of addition on the browse: The addition does not affect the current browse. For example, <Source>.ReadNext used after <Source>.Add positions on the record found after the current record before the addition. The hAffectBrowse constant has priority over the hWriteDefault constant. |
Remarks Managing automatic identifiers By default, the "automatic identifier" item is automatically updated when a record is added into a data file. There is no need to read the record again to find out the value of the automatic identifier. Simply use the following syntax: <File name>.<Name of automatic identifier item>. The hForceIdAuto and hSetIdAuto constants are used to modify the default behavior of the automatic identifier. Adding a record into a query Adding a record into a query can be performed: Regardless of the runtime mode of the query (with or without the hWithFilter constant), adding records into a query is allowed for the single-file queries only. The calculated items specified during the addition are ignored. They are automatically calculated. Caution: - No addition is allowed in a query that uses groups or aggregates.
- The management of integrity and duplicates is not performed during the operations on the multi-file queries: it is recommended to use transactions to avoid any problems.
Browsing and adding records You can configure the effect of adding a record during the browse of a data file ( hWriteDefault and hAffectBrowse constants). The behavior of earlier versions can be kept with the hAffectBrowse constant. Slowness when adding or deleting a record for the first time in an HFSQL data file Accessing a record in an HFSQL data file for the first time may take long. To fix this problem: - Disable the antivirus for .FIC,.NDX,.MMO and.REP files.
- Disable the "Restore the system" option in Windows XP.
Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|