PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK

  • Overview
  • Reminder
  • Automatic identifier calculated by the HFSQL engine
  • Forced automatic identifier (hForceIdAuto)
  • Fixed automatic identifier (hSetIdAuto)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Managing the automatic identifiers when adding a record
HFSQLAvailable only with this kind of connection
Overview

Reminder

Three management modes of automatic identifiers are available when adding a record into a HFSQL data file (HAdd):
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Automatic identifier calculated by the HFSQL engine
The automatic identifier is calculated by the HFSQL engine for each addition. This identifier is unique for each record of the data file.
Example: Adding a record into the CUSTOMER file.
When adding the record, the automatic identifier CUSTOMERID is automatically calculated by the HFSQL engine.
The last value of the automatic identifier was set to 6. The value of the automatic identifier for this new record will be set to 7.
Forced automatic identifier (hForceIdAuto)
The automatic identifier is not calculated during the addition. The identifier corresponds to:
  • the value assigned to the item by 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 value of the identifier found in memory (value of the identifier for the last record read in the file).
Once the record is added, the next automatic identifier calculated by default by the HFSQL engine will be calculated:
  • according to the last value of the automatic identifier.
  • without taking the value added by hForceIdAuto into account.
This management mode of the automatic identifier is useful when records are copied between several aliases of a data file. However, it should be used with great care because it could generate duplicates errors.
Example: Adding a record with forced automatic identifier into CUSTOMER file.
Two records are added to CUSTOMER file:
  • a record whose automatic identifier is forced to 15.
  • a record whose automatic identifier is calculated by the HFSQL engine. The automatic identifier of this record will be calculated according to the last value of the identifier (7 in our example).
In this example, no duplicate error will be generated until the value of the automatic identifier is set to 15: a duplicate error will occur when this record is added.
Fixed automatic identifier (hSetIdAuto)
The automatic identifier is not calculated during the addition. The identifier corresponds to:
  • the value assigned to the item by 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 default by the HFSQL engine will be calculated according to the greatest value of the identifier found in the data file. No duplicate error can occur on the unique identifier.
Example: Adding a record with fixed automatic identifier into CUSTOMER file.
Case #1: Two records are added to CUSTOMER file:
  • a record whose automatic identifier is forced to 3.
  • a record whose automatic identifier is calculated by the HFSQL engine. The automatic identifier of this record will be calculated according to the greatest value of the automatic identifier in the file (7).
Case #2: Two records are added to CUSTOMER file:
  • a record whose automatic identifier is forced to 10.
  • a record whose automatic identifier is calculated by the HFSQL engine. The automatic identifier of this record will be calculated according to the greatest value of the automatic identifier in the file (10).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment