ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Table functions
  • Use conditions
  • Type of search
  • Table control based on a data file
  • Miscellaneous
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
Warning
From version 27, TableSeek is kept for backward compatibility. This function is replaced by TableSearch.
Performs a search in:
  • a Table control,
  • a TreeView Table control,
  • WINDEV a table displayed in a Combo Box control.
Two search modes are available:
  • Search for an element in a column.
  • Search for an element in the stored value of control.
Example
// Searches for the "Shirt" element in the "COL_Product" column
// Generic search performed from row 5
let ResSearch = TableSearch(COL_Product, "Shirt", searchStartsWith, 5)
// Used to list all occurrences of a sought value.
Result1 is int
Result1 = TableSearch(COL_ColumnName, "SoughtValue", searchExactMatch)
WHILE Result1 <> -1
Trace(Result1)
Result1 = TableSearch(COL_ColumnName, "SoughtValue", ...
searchExactMatch, Result1 + 1)
END
Syntax

Searching for an element in a column Hide the details

<Result> = TableSearch(<Column name> , <Search element> [, <Type of search> [, <Source row>]])
<Result>: Integer
  • Index of the element found,
  • -1 if no element corresponds to the search.
If the search is performed:
  • in a Table control populated programmatically, the element found is not selected. To select the element found, use TableSelectPlus.
  • in a Table control based on a data file, the element found is not selected, the rows in the Table control scroll until the search element is reached.
<Column name>: Character string
Name of the column where the search is performed.
If this parameter corresponds to an empty string (""), the column to which the current process belongs will be used.
In a Table or TreeView Table control based on a data file, the search column must be bound to a key item. No search can be performed in a column that is not bound to an item.
<Search element>: Type of search element
Element to be found in the specified column. If the type of the search element is:
  • "Date" or "Time": the search is performed on the returned value.
  • "Currency + Euro": the search is performed on the stored currency.
<Type of search>: Optional Integer constant
Type of search to perform:
searchContainsGeneric search of type "Contains"
The elements whose value contains <Search element> are returned.
WEBDEV - Browser codePHP This constant is not available.
searchDefaultDefault search. for this function, the default search is an exact-match search (whose type is "Equals to").
The elements whose value is strictly equal to <Search element> are returned.
Caution: In a Table control populated programmatically, leading spaces are ignored.
WEBDEV - Browser codePHP This constant is not available.
searchExactMatch (or True for compatibility)
(Default value)
Exact-match search ("Equals to")
The elements whose value is strictly equal to <Search element> are returned.
Caution: In a Table control populated programmatically, leading spaces are ignored.
searchStartsWith (or False for compatibility)Generic search whose type is "Starts with"
The elements whose value starts with <Search element> are returned.
Caution: In a Table control populated programmatically, leading spaces are ignored.
<Source row>: Optional integer
Number of the source row for the search.
If this parameter is not specified, the search is performed in the entire column.
This parameter is used to find all the occurrences of a string in a column.
This parameter is ignored in Table controls based on a data file.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjax

Searching for an element in a Table control (stored value) Hide the details

<Result> = TableSearch(<Table control> , <Sought value>)
<Result>: Integer
  • Index of the element found,
  • -1 if no element corresponds to the search.
<Table control>: Control name
Name of the control to be used. This control can correspond to:
  • a Table control.
  • a TreeView Table control.
  • WINDEV a Combo Box control with table.
The Table control must be linked to a data file or to a variable.
<Sought value>: Type of search element
Value of the search element. This value is sought in the stored value of control.
Remarks

Use conditions

Syntax 1: Search in columns is available for:
  • Table or TreeView Table controls based on a data file.
  • Table or TreeView Table controls populated programmatically.
  • WINDEV tables displayed in a Combo Box control,
  • WEBDEV - Browser code Table controls in "Browser" mode,
  • single-selection or multi-selection controls.
    WEBDEV - Server codePHP Reminder: Multi-selection is not available for Table controls in "Server" mode.
For a Table or TreeView Table control based on a data file:
  • the iteration mode must be automatic.
  • the column must be bound to a key item.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjax Syntax 2: Search in stored values is available for:
  • Table or TreeView Table controls based on a data file.
  • Table or TreeView Table controls based on variables.
  • single-selection or multi-selection controls.
    WEBDEV - Server codePHP Reminder: Multi-selection is not available for Table controls in "Server" mode.

Type of search

  • Exact-match search: The elements whose value is strictly equal to <Search element> are returned by TableSearch. For example:
    // Return all customers whose name is "Smith" from "COL_NameColumn"
    TableSearch(COL_NameColumn, "Smith")
    Caution: In a Table control populated programmatically, leading spaces are ignored.
  • Generic search: The elements starting with <Search element> are returned by TableSearch.
    For example:
    // Return all customers whose name starts with "SMI"
    TableSearch(COL_NameColumn, "SMI", searchStartsWith)
WINDEVReports and QueriesAndroidiPhone/iPadUser code (UMC)PHP

Table control based on a data file

  • In a Table control based on a data file, the following syntax can be used to search for an element in a column:
    TableName = SearchElement
  • On Tables controls based on a data file with direct access to the data source, when TableSearch is called:
    • the display of the Table control is moved.
    • the returned index corresponds to an "approximate" index because this type of Table control can manage billions of records.

Miscellaneous

  • In a Table control populated programmatically, the search performed with TableSearch:
    • is not case sensitive.
    • ignores leading spaces.
  • In a Table control based on a data file, the search performed by TableSearch takes into account the search characteristics defined in the analysis for the item bound to the search column (case sensitivity, etc.).
Business / UI classification: UI Code
Component: wd300obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo TableSeek - Ler uma Coluna Tabela
FOR ALL ROW OF TABLE_local // aqui estou varrendo toda tabela
Info(TABLE_local.COL_nome_arquivo) // estou mostrando uma coluna
n_existe is int=TableSeek(TABLE_remoto.COL_nome_arquivo,TABLE_local.COL_nome_arquivo,True) // estou lendo uma coluna tabela
IF n_existe<>-1 THEN // verificando se existe na tabela
Info("Existe na Tabela")
ELSE
Info("nao existe")
END
END
De matos AMARILDO
03 Jan. 2016

Last update: 06/24/2022

Send a report | Local help