ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • The copied values
  • Using the lists of items
  • Array items
  • Errors that do not modify the destination record
  • Previous versions
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
HCopyRecord (Function)
In french: HCopieEnreg
ODBCNot available with this kind of connection
Copies:
  • the content of the current record (loaded in memory) to the current data file record.
  • WINDEVWEBDEV - Server codeAndroidAndroid Widget Java the content of a variable of type Record to the current data file record. The source data file and the destination data file do not necessarily have the same structure. Only the stored data of destination data file is modified. The destination data file will be modified when saving the current record.
HReadFirst(Customer, Name)
WHILE HOut(Customer) = False
// Adds the record to the data file Customer2
HCopyRecord(Customer2, Customer, hDefaultVal)
HAdd(Customer2)
// Goes to the next record
HReadNext(Customer, Name)
END
// Copy records from the Orders data file to an archive file
Orders_2019 is Data Source
 
// Create the archive file
HAlias(Order, Orders_2019)
HChangeName(Orders_2019, "Orders_2019")
HCréation(Orders_2019)
 
// Archive the orders
FOR EACH Orders where OrderDate = "20190101" TO "20191231"
// Adds the record to the archive file
HCopyRecord(Orders_2019, Orders, hDefaultVal)
HAdd(Orders_2019)
END
Syntax

Copying the current record Hide the details

<Result> = HCopyRecord(<Destination data file> , <Source data file> [, <Destination item> [, <Source item>]] [, <Options>])
<Result>: Boolean
  • True if the image was copied,
  • False if an error occurred. HError is used to identify the error.
<Destination data file>: Character string
Name of destination data file to use. The data will be copied into the current record of this data file.
<Source data file>: Character string
Name of source data file to use. The current record of this data file contains the information that must be copied.
<Destination item>: Optional character string
List of items found in the destination data file that must be assigned with the values read in the current record of source data file. The items must be separated by a comma or by a CR character (Carriage Return).
Remark: The composite keys cannot be defined as destination items. They will be automatically assigned.
Hyper File 5.5 This parameter is ignored.
<Source item>: Optional character string
List of items found in the source data file that must be copied into the current record of destination data file. The items must be separated by a comma or by a CR character (Carriage Return). These items must be classified according to the order in which they will be assigned in the destination items. The composite keys must be excluded from this list.
Hyper File 5.5 This parameter is ignored.
<Options>: Constant or combination of constants (optional)
Configures the copy:
hCopyAutoIDCopies the automatic identifier while keeping its value.
Remark: To use this constant you must use hSetIDAuto next time HAdd is called.
hDefaultValThe items of destination record that are not affected by the copy are initialized with their default value (defined in the data model editor).

If no parameter is specified, the automatic identifier is not copied and the unmodified items of destination record are not initialized.
Hyper File 5.5 This parameter is ignored.
WINDEVWEBDEV - Server codeAndroidAndroid Widget Java

Copying the record found in a Record variable Hide the details

<Result> = HCopyRecord(<Destination data file> , <Source record> [, <Destination item> [, <Source item>]] [, <Options>])
<Result>: Boolean
  • True if the image was copied,
  • False if an error occurred. HError is used to identify the error.
<Destination data file>: Character string
Name of destination data file to use. The data will be copied into the current record of this data file.
<Source record>: Record variable
Name of Record variable containing the information to copy.
<Destination item>: Optional character string
List of items found in the destination data file that must be assigned with the values read in the current record of source data file. The items must be separated by a comma or by a CR character (Carriage Return).
Remark: The composite keys cannot be defined as destination items. They will be automatically assigned.
Hyper File 5.5 This parameter is ignored.
<Source item>: Optional character string
List of items found in the source data file that must be copied into the current record of destination data file. The items must be separated by a comma or by a CR character (Carriage Return). These items must be classified according to the order in which they will be assigned in the destination items. The composite keys must be excluded from this list.
Hyper File 5.5 This parameter is ignored.
<Options>: Constant or combination of constants (optional)
Configures the copy:
hCopyAutoIDCopies the automatic identifier while keeping its value.
Remark: To use this constant you must use hSetIDAuto next time HAdd is called.
hDefaultValThe items of destination record that are not affected by the copy are initialized with their default value (defined in the data model editor).

If no parameter is specified, the automatic identifier is not copied and the unmodified items of destination record are not initialized.
Hyper File 5.5 This parameter is ignored.
Remarks

The copied values

The items whose name is common to both records are copied (and converted if necessary).
The items of the source record that do not exist in the destination record are not copied.
The items of the destination record that do not exist in the source record are not modified (except if the hDefaultVal constant is specified).
When copying an item whose value is NULL, the copied item is initialized to empty (empty string ("") for the strings and 0 for the numeric values) if the NULL value is not supported by the destination data file.
Remark: When the assignments are performed between different types of items, the type conversions follow the WLanguage standards.

Using the lists of items

Specifying two lists of items allows you to assign items with different names. The items are assigned in the order in which they appear in the lists.
If none of the two lists of items is supplied, only the items whose name is common to both records are copied.
If only the list of the destination items (<Destination item>) is specified, only the specified items will be copied.

Array items

When handling array items, HCopyRecord copies the maximum number of elements (starting from the first one).
If the array of the "source" record contains more elements than the array of the "destination" record, the additional elements of the "source" record are not copied.
If the array of the "source" record contains less elements than the array of the "destination" record, the additional elements of the "destination" record are not modified, except if the hDefaultVal constant is specified.
AndroidAndroid Widget Feature not available.

Errors that do not modify the destination record

The following errors do not modify the destination record:
  • no list is supplied and no item name is common to the two data files.
  • the list of items of a data file contains an item name that does not exist this data file.
  • the list of destination items contains a name of "composite key" item.
  • the list of destination items contains a name of "automatic identifier" item while the hCopyAutoID constant is not specified.
  • two lists of different sizes are specified.
WINDEV

Previous versions

This function replaces HCopyRecord_55, which is kept for compatibility with WINDEV 5.5.
Business / UI classification: Business Logic
Component: wd290hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/06/2023

Send a report | Local help