PC SOFT

WINDEV的在线文档

  • Overview
  • Creating a composite key
  • Composite key and link
  • Value of a composite key
  • Overview
  • Adding a record containing a composite key
  • Adding a record containing a composite key into a linked file
  • Building the value of a composite key to implement a search or a filter
  • WLanguage properties associated with composite keys
  • Using a composite key to perform exact-match searches
  • Exact-match search performed by H读查找第一个
  • Exact-match search and H读查找
  • Using a composite key to perform generic searches
  • Generic search performed by H读查找第一个
  • Generic search performed by H读查找
  • Using a composite key to create filters
  • Functions for creating filters
  • Filter between two values (bounds)
  • Filter from a given value
  • Filter on the first key components
  • Note: Filter with selection condition
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Overview
A composite key is a key item containing several other items. These items can be text items or numeric items.

A composite key is used to simplify the searches performed on several criteria.

The composite keys are binary items. Their value cannot be directly displayed (in a trace or in a control).

This page presents the following topics:

Creating a composite key
A composite key is created in the data model editor directly.

To create a composite key in a file description:

  1. Display the description of the file items ("Structure of files .. Items").Display the description of the file items:
    • Select the data file in the editor.
    • Display the popup menu (right mouse click) and select "Description of items".
  2. Click. A screen allowing you to build the composite key is displayed.
  3. The list of existing items is displayed in the table on the left. Double-click the items that must be included in the composite key. These items are displayed in the table on the right.
  4. Reorganize (if necessary) the items that belong to the composite key. Caution: the order of the items is important because it defines the sort order. For example, the "Name + State" composite key will be sorted on the name then on the state.
  5. Specify the search direction and the search parameters for each key component.
  6. Validate. The composite key is displayed in the list of file items.

Composite key and link

The composite keys can be used in the links between files. When describing the analysis, the composite key found in the linked file does no longer appear as a composite key but as a binary key. You will not be able to access the different components of the composite key in the linked file.

Note: The management of referential integrity is supported for a composite key used in a link.

Value of a composite key

Overview

A composite key is stored as a binary string. Its value cannot be displayed (neither in a control nor in the debugger, ...).

Adding a record containing a composite key

When adding or modifying a record containing a composite key, the value of the composite key is automatically defined according to the values of the different key components. No specific programming is required.

Adding a record containing a composite key into a linked file

When a record containing a composite key is added into a linked file, the value of the key must be built. Indeed, in the linked file, the composite key is not considered as being a composite key but as being a binary key. Therefore, a value must be assigned to it.

This value can be assigned:
  • directly. For example, a record was added into the Customer file. To add the value of the key into the linked file, all you have to do is perform a direct assignment:
LinkFile.NameDateCustomer.NameDate
  • via H创建键值. This function is used to build the value of the composite key from its components.

Building the value of a composite key to implement a search or a filter

When a filter or a search is implemented on a composite key, the value of the composite key must be defined (to define the lower bound and the upper bound of the filter for example).

Several methods allow you to build the value of a composite key:

Method 1: List of values:

All you have to do is specify the list of values that must be taken by each component of the composite key for the filter or for the search. The composite key is directly built in the syntax of the function.

Example: Find all the records in the CUSTOMER file whose last name is found between "AA" and "Barnaby" and whose first name is found between "Philomene" and "Tartuffe".

H过滤器CustomerLastNameFirstName, 【"AA""Philomene"】, 【"Barnaby""Tartuffe"】)

In this example, "AA","Zorro" is returned by the filter while "Philomene","Zorro" is not returned.

Example: Find all the records in the Tasks file whose tasks are included between 15/03/2011 00:00 and 25/03/2011 00:00.

H过滤器TasksTaskStarDateTaskStartTime, 【201103150000】, 【201103250000】)

Method 2: Using the FOR EACH statement

Specify the list of values that must be taken by each key component for the filter or for the search. The composite key is directly built in the syntax of the function.

Example: Finding the prospect customers living in state 69.

对于每个Contacts满足CCState等于【"Prospect"69
...
结束

Method 3: Using H创建键值

The value of a composite key can be built by H创建键值. To do so, the relevant data file, the name of the key and the values of the components must be specified in this function.

For example, the following code line is used to build the value of the composite key ("NAMEDATE") corresponding to "CUSTOMERNAME+ORDER_DATE" of Customer file:

H创建键值CustomerNAMEDATE"SMITH""03/11/99"

Method 4: Using HConvertX (method kept for backward compatibility with WinDev 5.5)

You must:

  • entirely fill the text components with the h.最小值 constant.
  • convert the numeric components with HConvert.
Example:

MyCompositeKey补全Customer.CustomerLastName维度Customer.LastName),h.最小值))+...
补全Customer.FirstName维度Customer.FirstName),h.最小值

WLanguage properties associated with composite keys

The following properties are used to manage the composite keys by programming:
二进制..二进制 is used to find out whether an item is a binary item or not.
复合键..复合键 is used to find out whether an item is a composite key.
组件..组件 is used to configure the different components of a composite key.
键格式..键格式 is used to configure the different components of a composite key.
组件数量..组件数量 is used to find out the number of elements found in a composite key.

Using a composite key to perform exact-match searches

Exact-match search performed by H读查找第一个

To perform an exact-match search on the value of a composite key, you must:
  1. Build the value of the sought key with H创建键值. All the values of the key components must be specified.
  2. Use H读查找第一个.
Note: By default, H读查找第一个 is used to perform an exact-match search.

ValCompKey缓冲区型
ValCompKeyH创建键值CustomerName_ZC"Smith""34000"
H读查找第一个CustomerName_ZCValCompKey
只要H找到()=
...
H读下一个CustomerName_ZC
结束

Exact-match search and H读查找

To perform an exact-match search on the value of a composite key, you must:
  1. Build the value of the sought key with H创建键值. All the values of the key components must be specified.
  2. Use H读查找 associated with the h.相同 constant.
Note: By default, H读查找 is used to perform a generic search. To perform an exact-match search, the h.相同 constant must be specified.

ValCompKey缓冲区型
ValCompKeyH创建键值CustomerName_ZC"Smith""34000"
H读查找CustomerName_ZCValCompKeyh.相同
只要H找到()=
...
H读下一个CustomerName_ZC
结束

Using a composite key to perform generic searches

Generic search performed by H读查找第一个

To perform a generic search on the value of a composite key, you must:
  1. Build the value of the sought key with H创建键值. Only the values of the first key components can be specified.
  2. Use H读查找第一个 associated with the h.相同 constant.
Note: By default, H读查找第一个 is used to perform an exact-match search. To perform a generic search, the h.通常 constant must be specified.

ValCompKey缓冲区型
ValCompKeyH创建键值CustomerName_ZC"Moore"
H读查找第一个CustomerName_ZCValCompKeyh.通常
只要H找到()=
...
H读下一个CustomerName_ZC
结束

Generic search performed by H读查找

To perform a generic search on the value of a composite key, you must:
  1. Build the value of the sought key with H创建键值. Only the values of the first key components can be specified.
  2. Use H读查找.
Note: By default, H读查找 is used to perform a generic search. To perform an exact-match search, the h.相同 constant must be specified.

ValCompKey缓冲区型
ValCompKeyH创建键值CustomerName_ZC"Moore"
H读查找CustomerName_ZCValCompKey
只要H找到()=
...
H读下一个CustomerName_ZC
结束

Using a composite key to create filters

Functions for creating filters

In addition to H过滤器, several WLanguage functions can be used to create specific filters. These functions can handle the composite keys:
H过滤器在一个数据库表,视图或查询上定义并启用一个过滤器。
H过滤器开头以Defines and enables a "Start with" filter on a file, view or query.
H过滤器介于Defines and enables an "Included between" filter on a file, view or query.
H过滤器相同Defines and enables a filter used to find the exact value of a string item.

Filter between two values (bounds)

To filter records between two specific values of a composite key, you must:
  1. Create the values of each bound with H创建键值.
  2. Create the filter with H过滤器 and specify the two bounds.
  3. Browse the selected records.
sFilterKey1H创建键值CUSTOMERNAME_ZC"MOORE""34000"
sFilterKey2H创建键值CUSTOMERNAME_ZC"MOORE""34999"
sSearchKeyH过滤器CustomerNAME_ZCsFilterKey1sFilterKey2
H读第一个CustomersSearchKey
只要不H超出()
...
H读下一个CustomersSearchKey
结束

Filter from a given value

To filter the records from a given value (without specifying any upper bound), you must:
  1. Create the value of the lower bound with H创建键值.
  2. Create the filter with H过滤器 and specify the lower and upper bounds. In this case, the upper bound is equal to the h.最大值 constant.
  3. Browse the selected records.
sFilterKeyH创建键值CUSTOMERNAME_ZC"MOORE""34000"
sSearchKeyH过滤器CustomerNAME_ZCsFilterKeyh.最大值
H读第一个CustomersSearchKey
只要不H超出()
...
H读下一个CustomersSearchKey
结束

Filter on the first key components

To filter the records on the first components of a composite key and to perform a sort on the following components, you must:
  1. Create the minimum and maximum values of the composite key with H创建键值. Only the first components must be specified.
  2. Create the filter with H过滤器 and specify the lower and upper bounds. In this case, the h.最小值 constant must be added to the lower bound and h.最大值 must be added to the upper bound. Notes: h.最小值 is equivalent to Char(0) and h.最大值 is equivalent to Char(255).
  3. Browse the selected records.

Note: Filter with selection condition

If the filter condition affects several items corresponding to a composite key of the file, the search key automatically selected by the filter will be this composite key.