PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK

  • Managing automatic identifiers
  • Modifying the deleted or crossed records
  • Modification conflict or deletion conflict
  • Managing the duplicates and the integrity
  • Version of the data file after a modification
  • Managing the binary memos
  • Modifying a record selected in a query
  • Browsing and modifying a record
  • xBase
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
HModify (Function)
In french: HModifie
ODBCNot available with this kind of connection
Modifies the specified record or the record found in memory in the data file (query or view). The indexes corresponding to all the keys used in the data file are automatically updated. The memos are added (if necessary) if the management of memos is enabled (HSetMemo.
After the call to HModify:
  • we recommend that you configure the management of errors:

    WEBDEV - Server code We advise you to check that no error was generated: Duplicate error, integrity error, password error, modification conflict error and status error during modification conflict. See Assisted management of HFSQL errors for more details.
  • If the management of duplicates is enabled and if the data file contains a unique key, HErrorDuplicates returns True if the value of modified key is not unique. The record is not modified.
  • if a lock problem occurs (attempt to modify a locked record), HErrorLock returns True and the record is not modified.

    PHP The management of locks is not available.
  • the number of the current record is not modified. By default, the current browse is not affected.
Note: This function can also be used on a HFSQL data file, view or query.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
// Finds the record
HReadSeekFirst(Customer, Name, "Smith")

IF HFound() = True THEN
// Modify a record in a file
// (record described by programming)
Customer.FirstName = "Vince"
Customer.City = "San Francisco"
Customer.Zip = "94102"
Customer.Country = "USA"
HModify(Customer)
END
// Modifies the current record of "Customer" file
// displayed in a window
ScreenToFile()
HModify(Customer)
Syntax
<Result> = HModify([<File name> [, <Record number> [, <Options>]]])
<Result>: Boolean
  • True if the record was modified,
  • False if a problem occurred (integrity error, duplicate error, etc.): the record is not modified. HError is used to identify the error.
<File name>: Optional character string (with or without quotes)
Name of data file, HFSQL view or query used. If this name is not specified, HModify handles the last data file used by the last function for HFSQL management (starting with the letter H).
<Record number>: Optional integer
Number of the record to modify. The record loaded in memory is re-written on the specified record.
If this number is greater than the total number of records found in the data file, intermediate deleted records will be created in order for the sequential reading of data file (HRead) to be consistent.

If this parameter is not specified (equal to 0 or to the hCurrentRecNum constant), HModify will modify the current record in the date file.

CAUTION: Do not confuse the record number with the automatic identifier associated with the record. In most cases, these two numbers are not identical. The record number is returned by HRecNum.

To use the <Options> parameter, <Record Number> must necessarily be specified.
Hyper File 5.5 This parameter is ignored.
PHPOLE DBNative Connectors (Native Accesses) This parameter must correspond to the current record number (hCurrentRecNum constant).
<Options>: Optional constant
Configures:
  • the effect of modification on the current browse,
  • the mode for calculating the automatic identifier,
  • the lock mode applied to the modified record. If no lock constant is specified, the modified record is unlocked.

    PHP The management of locks is not available.
  • the management of duplicates,
  • the management of integrity.
Note: To use this parameter, <Record Number> must necessarily be specified.
Hyper File 5.5 This parameter is ignored.
hAffectBrowseEffect of modification on the browse: The modification affects the browse.
For example, HReadNext used after HModify positions on the record found after the modified record (while taking its new values into account).
CAUTION: In any case (hAffectBrowse constant used or not): if HModify is used in a browse and if the value of search item is modified, the current record may be read again in the rest of browse. Indeed, the modification of search item updates the index key of file. This modification is taken into account when reading the next records.

The hAffectBrowse constant has priority over the hWriteDefault constant.
hLockNo
(default value)
Lock mode of modified record: No lock (even if HStartLock was used): the modified record will not be locked.
PHP This constant is not available.

hLockWriteLock mode of modified record: Lock in write mode: the modified 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.


PHP This constant is not available.

hLockReadWriteLock mode of modified record: Lock in read/write: the modified 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.


PHP This constant is not available.

hWriteDefault
(default value)
Effect of modification on the browse: The modification does not affect the current browse.
For example, HReadNext used after HModify positions on the record found after the current record before the modification.

CAUTION: If HModify is used in a browse and if the value of search item is modified, the current record may be read again in the rest of browse. Indeed, the modification of search item updates the index key of file. This modification is taken into account when reading the next records.

The hAffectBrowse constant has priority over the hWriteDefault constant.
hSetIdAutoMode 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 value of the identifier calculated by the HFSQL engine will correspond to the greatest value of the identifier in the file +1.
A WLanguage error occurs if the hSetIdAuto and hForceIdAuto constants are used at the same time.
hForceIdAutoMode for calculating the automatic identifier: 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 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.
hIgnoreDuplicatesManagement mode of duplicates: Ignores the duplicate check for this operation, even if the automatic duplicate check is enabled (HSetDuplicates).
A WLanguage error occurs if the hIgnoreDuplicates and hCheckDuplicates constants are used at the same time.
PHP This constant is not available.

hIgnoreIntegrityManagement mode of integrity: Ignores the integrity check for this add operation, even if the automatic integrity check is enabled (HSetIntegrity).
A WLanguage error occurs if the hIgnoreIntegrity and hCheckIntegrity constants are used at the same time.
PHP This constant is not available.

hRecalculateIdAutoMode for calculating the automatic identifier: The automatic identifier of the record will be re-calculated during the write operation. This constant has priority over hForceIdAuto and hSetIdAuto.
PHP This constant is not available.
hCheckDuplicatesManagement mode of duplicates: Checks the duplicates for this operation, even if the duplicate check is disabled (HSetDuplicates).
A WLanguage error occurs if the hIgnoreDuplicates and hCheckDuplicates constants are used at the same time.
PHP This constant is not available.

hCheckIntegrityManagement mode of integrity: Checks the integrity of operation even if the automatic integrity check is disabled (HSetIntegrity).
A WLanguage error occurs if the hIgnoreIntegrity and hCheckIntegrity constants are used at the same time.
PHP This constant is not available.

Hyper File 5.5 The text items are automatically filled with space characters.
Remarks
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Managing automatic identifiers

By default (without using the constants for modifying the automatic identifier), HModify applied to an active record or to a crossed record does not modify the automatic identifier (even if the automatic identifier was assigned in the language): the automatic identifier found in the data file is re-used.
The hForceIdAuto and hSetIdAuto constants are used to modify the default behavior of the automatic identifier.
PHPOLE DBNative Connectors (Native Accesses)
  • 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 requested value.
    Note: the hForceIdAuto constant is equivalent to hSetIdAuto: the automatic identifier calculated by HFSQL 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.
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Modifying the deleted or crossed records

Modifying a crossed record or a deleted record re-enables the record.
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Modification conflict or deletion conflict

The errors of modification conflict and the errors of deletion conflict occur only if HModify is applied to the current record. Indeed, no conflict can occur if a record number is specified as the record has not been read before the modification.

Managing the duplicates and the integrity

The integrity check and the duplicate check are performed on the keys for which:
  • a check is enabled,

    and
  • the value of the item is modified in relation to the record found in the data file.
Example:
...
CUSTOMER.LastName = "TUBE"
CUSTOMER.FirstName = "Vince"
HAdd(CUSTOMER)    // integrity check and duplicate check performed on
// LastName and FirstName if active management
CUSTOMER.FirstName = "Mark"
HModify(CUSTOMER)   // integrity check and duplicate check performed on
// FirstName only if active management
...
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Version of the data file after a modification

If the record was modified (no duplicate error and no integrity error), the version number of the data file is modified. To find out the version number, use HVersion.
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5OLE DBNative Connectors (Native Accesses)

Managing the binary memos

When a record is modified, the memos are modified if necessary (if the management of memos is enabled by HSetMemo).
Reminder: to initialize a binary memo item, use HLinkMemo.
WEBDEV - Server codePHPAjaxHFSQLHFSQL Client/ServerStored procedures

Modifying a record selected in a query

The modification of a record in a query can be performed:
  • in the query result
  • in the data files handled by the query (hModifyFile constant used in HExecuteQuery or HExecuteSQLQuery). In this case, the hWithFilter constant is automatically selected.
We must distinguish between two cases, depending on the runtime mode of the query (with or without the hWithFilter constant).
Running the query with the hWithFilter constant
  • Only the modification of the current record is allowed.
  • If the function is run to modify a query based on several data files, the modification is applied to the linked data files.
  • A WLanguage error occurs when the content of a calculated item is modified. The content of these items is automatically calculated when modifying the record.
Running the query without the hWithFilter constant
  • If the function is run to modify a query based on several data files, the modification is applied to the linked data files.
  • If the modified record does no longer correspond to the query selection, the record will still be found in the result of the query
  • A WLanguage error occurs when the content of a calculated item is modified. The content of these items is automatically calculated when modifying the record.
Caution:
  • No modification is allowed in a query that is using the groups or the aggregates.
  • The management of integrity and duplicates is not performed during the operations on the multi-file queries: we recommend that you use the transactions to avoid any problem.
WEBDEV - Server codePHPAjaxStored proceduresOLE DBNative Connectors (Native Accesses)

Browsing and modifying a record

If the modification is performed during a browse, the modified record will be visible in the current browse only. If other browses have been defined on this database, the modified record will be visible once these browses have been re-initialized.
Using the hAffectBrowse constant slows down the modification because the table or the query is refreshed.
CAUTION: If HModify is used in a browse and if the value of search item is modified, the current record may be read again in the rest of browse. Indeed, the modification of search item updates the index key of file. This modification is taken into account when reading the next records.
WEBDEV - Server codeNative Connectors (Native Accesses)

xBase

HDelete and HCross have the same effect: the record is crossed but it is not deleted. Therefore, the record can be re-enabled by HModify. In this case, HState returns the hStateCrossed constant for a deleted record (instead of hStateDel).
Component : wd240hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Cambio de ID o Primary Key
Como puedo cambiar una llave primaria con hmodify, le asigno el valor manualmente pero no se afecta al guardar.
Mecias SAMUEL
13 Mar. 2018