PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

  • Managing automatic identifiers
  • Modifying the deleted or crossed records
  • Modification conflict or deletion conflict
  • Managing duplicates and integrity
  • Version of the data file after a modification
  • Managing binary memos
  • Modifying a record selected in a query
  • Modifying and looping through a record
  • xBase
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>.Modify (Function)
In french: <Source>.Modifie
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 (<Source>.SetMemo.
After the call to <Source>.Modify:
  • it is recommended to configure the management of errors:
    WINDEV WINDEV proposes an automatic management of errors for the following 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.
    WEBDEV - Server code It is recommended to check that no error was generated: Duplicate error, integrity error, password error, modification conflict error and status error during modification conflict. 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 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.
    Java Access by JDBC: The management of locks is not available for databases accessed by JDBC.
  • the number of the current record is not modified. By default, the current iteration is not affected.
Remark: This function can be used on a data file, an HFSQL view or a query.
Example
// Finds the record
Customer.ReadSeekFirst(Name, "Smith")
 
IF Customer.Found() = True THEN
// Modify a record in a data file
// (record described through programming)
Customer.FirstName = "Vince"
Customer.City = "San Francisco"
Customer.Zip = "94102"
Customer.Country = "USA"
Customer.Modify()
END
// Modify current record of "Customer"
// displayed in a window
Customer.ToFile()
Customer.Modify()
Syntax
<Result> = <Source>.Modify([<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.
<Source>: Type corresponding to the specified source
Name of data file, HFSQL view or query used.
<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 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>.Modify will modify the current record in the data 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 <Source>.RecNum.

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).
Java Access by JDBC: This parameter must correspond to the current record number (hCurrentRecNum constant).
<Options>: Optional constant
Configures:
  • the effect of modification on the current iteration,
  • 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.
    Java Access by JDBC: The management of locks is not available for databases accessed by JDBC.
  • the management of duplicates,
  • the management of integrity.
Remark: To use this parameter, <Record number> must necessarily be specified.
Hyper File 5.5 This parameter is ignored.
hAffectBrowseEffect of modification on the iteration: The modification affects the iteration.
For example, <Source>.ReadNext used after <Source>.Modify 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 <Source>.Modify is used in an iteration and the value of the browse item changes, the current record may be read again in the rest of the iteration. Modifying the browse item updates the file index key. This modification is taken into account when reading the next records.

The hAffectBrowse constant has priority over the hWriteDefault constant.
hCheckDuplicatesManagement 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.
PHP This constant is not available.

Java Access by JDBC: This constant is not available.
hCheckIntegrityManagement 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.
PHP This constant is not available.

Java Access by JDBC: This constant is not available.
hFalsifyTimestampManagement of Timestamp items: By default, a Timestamp item contains the date and time the record was created/modified. This date/time is automatically calculated.
This constant prevents the Timestamp item from being updated: the last value in the record will be kept.
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 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.
hIgnoreDuplicatesManagement 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.
PHP This constant is not available.

Java Access by JDBC: 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 (<Connection variable>.SetIntegrity).
A WLanguage error occurs if the hIgnoreIntegrity and hCheckIntegrity constants are used at the same time.
PHP This constant is not available.

Java Access by JDBC: This constant is not available.
hLockNo
(default value)
Lock mode of modified record: No lock: the modified record will not be locked.
PHP This constant is not available.

Java Access by JDBC: 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.

Java Access by JDBC: 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.

Java Access by JDBC: 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.
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.
hWriteDefault
(default value)
Effect of modification on the iteration: The modification does not affect the current iteration.
For example, <Source>.ReadNext used after <Source>.Modify positions on the record found after the current record before the modification.

CAUTION: If <Source>.Modify is used in an iteration and the value of browse item changes, the current record may be read again in the rest of the iteration. Modifying the browse item updates the file index key. This modification is taken into account when reading the next records.

The hAffectBrowse constant has priority over the hWriteDefault constant.
Hyper File 5.5 The text items are automatically filled with space characters.
Remarks
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadJavaExternal languagePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Managing automatic identifiers

By default, <Source>.Modify does not change the automatic identifier when used on an active or crossed record (even if the automatic identifier was assigned in the code): the automatic identifier in the data file is reused.
The hForceIDAuto and hSetIDAuto constants are used to modify the default behavior of the automatic identifier.
For more details, see Managing the automatic identifier during a modification.
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 desired value.
    Remark: 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.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadJavaExternal languagePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Modifying the deleted or crossed records

Modifying a crossed record or a deleted record re-enables the record.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadExternal languagePHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5

Modification conflict or deletion conflict

Modification or deletion conflict errors appear only if <Source>.Modify is used on the current record. If a record number is specified, there can be no conflict, since the record was not read before the modification.
For more details, see Assisted HFSQL error handling.

Managing duplicates and integrity

The integrity and duplicate checks 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 = "Milo"
Customer.Add()    // integrity and duplicate check performed on
// LastName and FirstName if active management
Customer.FirstName = "Mark"
Customer.Modify()   // integrity and duplicate check performed on
// FirstName only if active management
...
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadJavaPHPAjaxHFSQLHFSQL 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 get the version number, use <Source>.Version.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadJavaPHPAjaxHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5OLE DBNative Connectors (Native Accesses)

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 codeUniversal Windows 10 AppiPhone/iPadJavaPHPAjaxHFSQLHFSQL Client/ServerStored procedures

Modifying a record selected in a query

The modification of a record in a query can be performed:
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 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.
WINDEVWEBDEV - Server codeJavaPHPAjaxStored proceduresOLE DBNative Connectors (Native Accesses)

Modifying and looping through a record

If the modification is performed during an iteration, the modified record will be visible in the current iteration only. If other iterations have been defined on this database, the modified record will be visible once these iterations have been reinitialized.
Using the hAffectBrowse constant slows down the modification because the table or the query is refreshed.
CAUTION: If <Source>.Modify is used in an iteration and the value of browse item changes, the current record may be read again in the rest of the iteration. Modifying the browse item updates the file index key. This modification is taken into account when reading the next records.
WINDEVWEBDEV - Server codeNative Connectors (Native Accesses)

xBase

<Source>.Delete and <Source>.Cross have the same effect: the record is crossed but it is not deleted. Therefore, the record can be re-enabled using <Source>.Modify. In this case, <Source>.State returns the hStateCrossed constant for a deleted record (instead of hStateDel).
Business / UI classification: Business Logic
Component: wd270hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment