ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Generic search/Exact-match search
  • Exact-match search in Access
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
  • Looping through records that match a condition
  • Optimizing iterations
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Positions on the first file record whose value for a specific item is greater than or equal to a sought value (generic search). The record is read and the corresponding HFSQL variables are updated.
In most cases, <Source>.ReadSeek sets the position in the data file to loop through the records that match a condition. <Source>.ReadNext is used to read the next record corresponding to the condition.Several cases may occur after the call to <Source>.ReadSeek:
  • a record corresponding to the condition has been found, blocked (if necessary) and loaded into memory: function <Source>.Found returns True.
    Java JDBC access: lock management is not supported for databases that are accessed through JDBC.
  • the data file is empty or there is no record corresponding to the condition: no read is performed and function <Source>.Out returns True.
This function can be used with the data files, HFSQL views or queries.
Remarks:
  • By default, <Source>.ReadSeekFirst and <Source>.ReadSeekLast are used to perform exact-match searches.
  • By default, <Source>.ReadSeek is used to perform a generic search on strings. This search is not generic on integers, reals, dates, currencies, etc.
Example
// Find the first record 
// for which the Customer name is MOORE
Customer.ReadSeek(Name, "MOORE")
IF Customer.Found() THEN
	Trace("Customer MOORE found")
ELSE
	Trace("Customer MOORE not found")
END
Syntax
<Result> = <Source>.ReadSeek(<Item> , <Search value> [, <Options>])
<Result>: Boolean (optional)
Corresponds to:
  • True if the sought record was found and read. The file buffer is loaded with the data of the record found. In this case, HError is set to 0 and <Source>.Found is set to True.
  • False in the following cases:
    • error while accessing the file (unable to read for example). HError returns an error code. HErrorInfo returns more details about the error. In this case, <Source>.Found cannot be used.
    • the access to the file was performed but no record was found. In this case, HError is set to 0 and <Source>.Found is set to False.
    Warning: In this case, the file buffer cannot be used..
<Source>: Type corresponding to the specified source
Name of data file, HFSQL view or query used.
<Item>: Character string
Name of item on which the search will be performed.
For an exact-match search, this parameter can correspond to a non-key item.
Hyper File 5.5 To perform generic searches on a composite key, all the components of the composite key must be text components. Otherwise, an exact-match search is performed.
<Search value>: Type corresponding to the value
Value of the sought item.
<Options>: Optional constant (or combination of constants)
Used to configure:
  • the lock mode applied to the sought record.
  • the type of search performed.
hIdenticalExact-match search (see the Notes)
A generic search is performed by default (constant not specified).
Java JDBC access: This constant is not available.
hKeepFilterThe filter set by <Source>.Filter will be taken into account, even if the search key is not optimized for the filter. Reminder: <Source>.Filter returns the optimized search key for the filter.
Caution: in this case, on large data files, performance problems may occur..
Hyper File 5.5 This variable cannot be used.
hLimitParsing
ODBCNative Connectors (Native Accesses) The iteration will stop when the last searched value is found. The current record will correspond to this last record found.
<Source>.Found will be set to False and <Source>.Out will be set to True.
This constant is used to optimize the search speed in Client/Server mode.
This constant is recommended when performing a simple search (without looping through the found elements).
HFSQL Client/Server This constant is not available.
hLockNoNo blocking: the recording can be played back or modified by another application during playback..
PHP The management of locks is not available.
Java JDBC access: This constant is not available.
hLockReadWriteRead/write lock: the record being read cannot be read or modified by another application.
The lock mode is ignored if a query is used.
ODBC Lock in write-only. Operating mode equivalent to the hLockWrite constant.
PHP The management of locks is not available.
Java JDBC access: This constant is not available.
hLockWriteWrite lock: the record currently read can be read by another application but it cannot be modified by another application.
The lock mode is ignored if a query is used.
PHP The management of locks is not available.
Java JDBC access: This constant is not available.
hNoRefresh
PHPODBCNative Connectors (Native Accesses) <Source>.ReadSeek does not refresh the content of the table or query. If possible, the query is not re-run. All the saved positions are stored.
ODBCNative Connectors (Native Accesses) The lock options will have no effect if the locks are not supported by the OLE DB provider or by the Native Connector.
Java JDBC access: lock management is not supported for databases that are accessed through JDBC.
Remarks
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Generic search/Exact-match search

A generic search or an exact-match search will be performed according to <Sought value>.
  • Generic search search for all records beginning with the specified value
    To perform a generic search, the desired value must be specified in <Sought value>.
    Note: For compatibility with WINDEV 5.5, the generic search for an empty string ("") is equivalent to using the <Source>.ReadFirst function.
  • Exact-match search search for all records exactly matching the specified value.
    To perform an exact-match search, the size of the search argument must be exactly the same as the size of the key. To perform an exact-match search, you also have the ability to use the hIdentical constant.
    To perform an exact-match search, you also have the ability to use <Source>.ReadSeekFirst.
Please note If you're using Hyper File 5.5 files or files in Hyper File 5.5 format migrated to HFSQL Classic, the implementation of generic and exact-match searches may vary. For more details, see the Hyper File 5.5 and HFSQL Classic: How are spaces handled in searches? table
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjaxNative Connectors (Native Accesses)

Exact-match search in Access

To perform an exact-match search on an ACCESS database, it is recommended to use NoSpace if there are space characters at the end of the sought value.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadJavaUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Performing a search on a composite key

Several methods can be used to perform a search on a composite key:
1. Using a list of values
The following syntax is used to perform a search on a composite key:
HReadSeek(<File name>, <Name of composite key>,
[<Search value of first element of composite key>,
<Search value of first element of composite key>, ...])
Example:
// Find the record
Customer.ReadSeek(LastName_FirstName, ["MOORE","Vince"])

WHILE Customer.Found()
	// Process
	Customer.ReadNext(LastName_FirstName)
END

2. Using <Source>.BuildKeyValue
If the sought item is a composite key, the value to find can be built by <Source>.BuildKeyValue.
Hyper File 5.5 To perform generic searches on a composite key, all the components of the composite key must be text components. Otherwise, an exact-match search is performed.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadJavaUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Search on an array item

The search is performed on the first array element (element with index 1). To perform a search on the other array elements, use the filters or queries.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadJavaUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Search and filter

If a filter is enabled (<Source>.Filter), the filter is taken into account by the search only if the key used is identical.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadJavaUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Looping through records that match a condition

In most cases, <Source>.ReadSeek sets the position in the data file to loop through the records that match a condition. <Source>.ReadNext and <Source>.ReadPrevious are used to read the next and previous matching records.
To ignore the search while going to the next or previous record, use one of the following functions:
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Optimizing iterations

To optimize the first iterations on a data file, use <Source>.Optimize on this data file.
Component: wd300hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/07/2024

Send a report | Local help