Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Example 1: Creating an alias to use the data found in an archived file
  • Example 2: Copying data between two files with the same structure
Example 1: Creating an alias to use the data found in an archived file
WINDEVWEBDEV - Server codeReports and QueriesWindowsJavaUser code (UMC)AjaxHFSQL ClassicStored procedures The following example is used to handle the data found in the Orders2013 file (order file for the year 2013) archived in the D:\SalesMgt\Archive2013 directory. This file corresponds to the description of the ORDERS file in the analysis.
// Create an alias for the ORDERS file
// (Syntax available from version 19)
Orders2013 is Data Source <description=Orders>
IF HAlias(Orders, Orders2013) = True THEN
// ORDERS2013 can now be used in the processes
// It behaves the same way as
// the ORDERS file described in the analysis.
// Modify the directory
HChangeDir(Orders2013, "D:\SalesMgt\Archive2013")
// Modify the name
HChangeName(Orders2013, "Orders")
// Processes on the Orders2013 file
// Cancel the alias
Example 2: Copying data between two files with the same structure
WINDEVWEBDEV - Server codeWindowsJavaUser code (UMC) This example is used to copy the records found in TempCustomer.Fic to Customer.Fic. The TemCustomer file in this example is an existing file containing the customers that will be copied into the Customer file.
// Declare the alias
TempCustomer is Data Source <description=Customer>
// (Syntax available from version 19)
// Create alias
IF HAlias(Customer, TempCustomer) = True THEN
// If TempCustomer.FIC is found in another directory,
// you must add:
// HChangeDir(TempCustomer,"C:\MyDir\AliasDir")
// Physically create (or open) the TempCustomer.Fic file
  // To filter the copied elements,
// add an HFilter function here
  // Browse the records found in TempCustomer.Fic
  HReadFirst(TempCustomer, "CustomerName")
  WHILE NOT HOut(TempCustomer)
// Copies the record in memory
// from TempCustomer.Fic file to Customer.Fic file
 IF HCopyRecord(Customer, TempCustomer) THEN
 // Add into Customer.Fic
 // Automatic file identifier recalculated if it exists
 // Addition OK? (check the integrity and duplicates)
 IF HErrorDuplicates() = True OR ...
HErrorIntegrity() = True THEN
  IF YesNo("Duplicates error " + ...
"or integrity error "+ ...
"while adding " + ...
Customer.CustomerName + CR + ...
"Continue?") = False THEN
// Stop processing the copy of records
// Exit from the WHILE loop
// Error on HCopyRec function
// Display an error message
Error("Unable to copy the records")
// Interrupt the process
// Exit from the WHILE loop
  HReadNext(TempCustomer, "CustomerName")
// Error on HAlias function
// Display a message for the error
  Error("Error details" + HErrorInfo())
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help