Running a query and handling the result in WLanguage
The selection of records performed by query is not necessarily displayed in a report, in a window, ... This selection can also be used in programming.
Most of the HFSQL functions (browse, search, read, ...) can be used both on data files and on the query result. To use these functions on a query, you need to execute the query first (with HExecuteQuery
For example, the Customer34 query selects all the customers whose zip code starts with 34. The PrintCustomer procedure is used to print a proforma invoice for each customer. The following code is used to browse the result of the Customer34 query and to print an invoice for all the selected customers.
// Run the query
ResExecute = HExecuteQuery(Customer34)
// Error while running the query?
IF ResExecute = True THEN
// Browse the result of the query
FOR EACH Customer34
// Print the invoice for each record
PrintCustomer(Customer34.CustomerLName, Customer34.CustomerFName, ...
Customer34.CustomerAddress, Customer34.CustomerZipCode, ...
// Display the error message
Error("The query was not run.")
- Analysis password: If the query is associated with an analysis protected by password at runtime, this password must be specified when opening the analysis (HOpenAnalysis) in the initialization process of the project.
- File password: If the query is based on one or more password-protected files, specify the passwords with HPass before executing the query (with HExecuteQuery).
This page is also available for…