PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK

New WINDEV, WEBDEV, WINDEV Mobile 25 feature!
  • Generic search/Exact-match search
  • Search performed on a key item or on a non-key item
  • Performing a search on a composite key
  • Search and filter
  • Search on an array item
  • Browsing the records corresponding to a condition
  • Exact-match search in Access
  • Locks
  • Optimizing the browse operations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Positions on the last record of a data file whose value for a specific item is less than or equal to a sought value (exact-match search). The record is read and the corresponding HFSQL variables are updated.
In most cases, <Source>.ReadSeekLast is used to set the position in the data file to perform a browse loop among the records that correspond to a condition. <Source>.ReadPrevious is used to read the previous record corresponding to the condition.
Several cases may occur after the call to <Source>.ReadSeekLast:
  • a record corresponding to the condition was found, locked (if necessary) and loaded in memory: <Source>.Found returns True.
    Windows Mobile Locks are only managed on HFSQL Client/Server data files or data files handled by a Native Access. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
    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 data file is empty or there is no record corresponding to the condition: no reading is performed and <Source>.Out returns True.
  • the function tries to lock a record that is already locked in read-only: no reading is performed, HErrorLock is set to True and <Source>.Out returns True.
    Windows Mobile The management of locks is only performed on HFSQL Client/Server data files or data files handled by a native access. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
    PHP The management of locks is not available.
    Java Access by JDBC: The management of locks is not available for databases accessed by JDBC.
This function can be used with the data files, HFSQL views or queries.
Remark: the search can be canceled by <Source>.CancelSeek.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
// Find the last record for which
// the Customer name is MOORE
Customer.ReadSeekLast(NAME, "MOORE")
// Find all the customers whose turnover is less than a specific value
Customer.ReadSeekLast(Turnover, X)
WHILE NOT Customer.Out()
AddCustomerList()
Customer.ReadPrevious(Turnover)
END
Syntax
<Result> = <Source>.ReadSeekLast(<Item> , <Sought value> [, <Options>])
<Result>: Boolean
  • True if the record was found (corresponds to the value of <Source>.Found).
  • False if a problem occurred. This problem can be caused by:
<Source>: Type corresponding to the specified source
Name of data file, HFSQL view or query used.
<Item>: Character string (with or without quotes)
Name of item on which the search will be performed. This item can be a search key or not.
Hyper File 5.5 The search can only be performed on a key item.
<Sought value>: Type corresponding to the value
Value of 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.
hLockReadWriteLock in read/write: the record currently read cannot be read or modified by another application.
The lock mode is ignored if a query is used.
OLE DB Lock in write-only. Operating mode equivalent to the hLockWrite constant.
PHP This constant is not available.
Java Access by JDBC: This constant is not available.
hLockWriteLock in write mode: 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 This constant is not available.
Java Access by JDBC: This constant is not available.
hLockNoNo lock (even if HStartLock was called): the record can be read or modified by another application during the reading.
PHP This constant is not available.
Java Access by JDBC: This constant is not available.
Versions 17 and later
hForwardOnly
New in version 17
hForwardOnly
hForwardOnly
Native Connectors (Native Accesses) Constant that can only be used with Native Accesses.
Used to speed up the browse of data during a simple browse that does not use the following features:
  • Read the previous record.
  • Modify a record.
  • Save the position.
If one of these features is used, the result may differ from the expected one.
This constant can be used for example during a browse used to fill a memory table.
hGenericGeneric search (see the Notes)
An exact-match search is performed by default (constant not specified).
hLimitParsingThe browse will stop as soon as the last sought value is found. The current record will correspond to this last record found.
<Source>.Found will return False and <Source>.Out will return True.
This constant is used to optimize the search speed in Client/Server mode.
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 search key optimized for the filter.
Caution: in this case, performance issues may arise for large files.
Hyper File 5.5 This variable cannot be used.
By default, the browse performed after <Source>.ReadSeekLast ignores the filter.
hNoRefresh
OLE DBNative Connectors (Native Accesses) <Source>.ReadSeekLast does not refresh the content of the table or query. If possible, the query is not re-run. All the saved positions are stored.
Windows Mobile Locks are only managed on HFSQL Client/Server data files or data files handled by a Native Access. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
PHP The management of locks is not available.
Java Access by JDBC: The management of locks is not available for databases accessed by JDBC.
OLE DBNative Connectors (Native Accesses) Lock options will have no effect if the OLE DB provider or Native Connector (also called Native Access) does not support locks.
OLE DB The lock mode specified by <Source>.ReadSeekLast will remain effective during the calls to <Source>.ReadPrevious and <Source>.ReadNext.
To modify the lock mode, you must use:
Remarks

Generic search/Exact-match search

  • Generic search (mainly on the Character String items): Finds all records starting with the specified value.
    For example: When a generic search is performed on "Smith" (for the NAME item), all records whose Name item starts with "Smith" will match the search. Therefore, the record containing "Smither" will match the search (<Source>.Found will return True).
    Remark: For backward compatibility with version 5.5, the generic search of an empty string ("") is equivalent to the use of <Source>.ReadLast.
  • Exact-match search: Finds all records that exactly correspond to the specified value.
    For example: When an exact-match search is performed on "Smith" (for the NAME item), <Source>.Found returns True for the records whose item exactly matches "Smith".
  • Examples of searches performed on CUSTOMER file sorted by name:
Sought valueOptions<Source>.ReadSeekLast positions on the record.HFound returnsHOut returnsExplanations
Davon6TrueFalseDavon exists.
The beginning of data file was not reached yet.
Davo5FalseFalseDavo does not exist. Positioning on the first lower value (Moore).
The beginning of data file was not reached yet.
MoorhGeneric5TrueFalseMoor does not exist but the search is generic, and Moore is found (among others).
The beginning of data file was not reached yet.
MoorThe record was not found (no move).FalseFalseMoor does not exist.
The beginning of data file was not reached yet.
BernardThe record was not found (no move).FalseTrueBernard does not exist.
Positioning on the first lower value (this value does not exist): the beginning of data file was reached.

Search performed on a key item or on a non-key item

The search can be performed on a key item or a non-key item.
If the search is performed on a key item:
  • the search is fast and the result is sorted.
  • if the browse is continued by <Source>.ReadPrevious, the next records will correspond to the values less than or equal to the sought value. In this case, <Source>.Out must be checked after each read operation to find out whether the beginning of the file has been reached.
If the search is performed on a non-key item:

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:
HReadSeekLast(<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.ReadSeekLast(LastName_FirstName, ["MOORE","Vince"])

2. Using <Source>.BuildKeyValue
Example:
bufSoughtVal is Buffer = Customer.BuildKeyValue(LastName_FirstName, sLastName, sFirstName)
Customer.ReadSeekLast(LastName_FirstName, bufSoughtVal)
WHILE Customer.Found()
Customer.Delete()
Customer.Previous(LastName_FirstName)
END

3. Using HConvert
To build the value of a composite key without using <Source>.BuildKeyValue, you must:
  • fill the text components on their entire size with Charact(0).
  • convert the numeric components with HConvert.
Example:
MyCompositeKey = Customer.CustomerLastName.Complete(Dimension(Customer.LastName), Charact(0)) + ...
Customer.FirstName.Complete(Dimension(Customer.FirstName), Charact(0))
Hyper File 5.5 To perform generic searches on a composite key, all the components of composite key must be Text components. Otherwise, an exact-match search is performed.

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.
To take this filter into account in the rest of browse (even if the search key is not optimized for the filter), use the hKeepFilter constant.
Hyper File 5.5 If a filter is enabled, the filter is ignored by the search.

Search on an array item

The search is performed on the first array element (element whose subscript is 1). To perform a search on the other array elements, use the filters or queries.

Browsing the records corresponding to a condition

In most cases, <Source>.ReadSeekLast is used to set the position in the data file to perform a browse loop among the records that correspond to a condition. <Source>.ReadNext and <Source>.ReadPrevious are used to read the next and previous records corresponding to the condition.
To ignore the search while going to the next or previous record, use one of the following functions:
WINDEVWEBDEV - Server codeReports and QueriesAjaxUser code (UMC)External languageStored proceduresOLE DB

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/iPadUniversal Windows 10 AppWindows MobileAjaxUser code (UMC)External languageHFSQLHFSQL Client/ServerStored proceduresHyper File 5.5OLE DBNative Connectors (Native Accesses)

Locks

The locks apply only when a record was found.
By default (no lock mode specified in <Options>), the record is not locked.
If a lock is erquested (hLockWrite or hLockReadWrite constant), the record will be read only if this record is not already locked.
There is no need to specify a lock parameter if the data file is locked by HStartLock: the lock specified by HStartLock is automatically taken into account. To ignore the lock set by HStartLock, use the hLockNo constant.
Reminder: A locked record can be unlocked by <Source>.UnlockRecNum.
OLE DBNative Connectors (Native Accesses) Lock options will have no effect if the OLE DB provider or Native Connector (also called Native Access) does not support locks.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUniversal Windows 10 AppAjaxUser code (UMC)HFSQLStored procedures

Optimizing the browse operations

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