- 创建
- 脚本语法和图表函数
- 脚本和图表表达式中的函数
- 内部记录函数
- Exists - 脚本函数
Exists - 脚本函数
Exists() 用于确定是否已经将特定字段值加载到数据加载脚本中的字段。此函数用于返回
Syntax:
Exists(field_name [, expr])
Return data type: 布尔值
Arguments:
参数 | 说明 |
---|---|
|
用于评估要搜索的字段名称的名称或字符串表达式。字段到目前为止必须存在于由脚本加载的数据中。 |
|
对字段值进行求值以便查找在 field-name 中指定的字段的表达式。如果省略,指定字段中的当前记录值为假设值。 |
示例 | 结果 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Exists (Employee) |
如果当前记录中的字段值 Employee 已存在于任何以前已读入的包含该字段的记录,则返回 -1 ( |
||||||||||
Exists(Employee, 'Bill') |
如果在字段 Employee 的当前内容中发现字段值 'Bill',则返回 -1 ( 语句 Exists (Employee, Employee) 和 Exists (Employee) 功能相同。 |
||||||||||
Employees: LOAD * inline [ Employee|ID|Salary Bill|001|20000 John|002|30000 Steve|003|35000 ] (delimiter is '|');
Citizens: Load * inline [ Name|Address Bill|New York Mary|London Steve|Chicago Lucy|Paris John|Miami ] (delimiter is '|');
EmployeeAddresses: Load Name as Employee, Address Resident Citizens where Exists (Employee, Name);
Drop Tables Employees, Citizens; |
|
||||||||||
使用以下语句替换前一个示例的样本数据中构建表格 NonEmployee: Load Name as Employee, Address Resident Citizens where not Exists (Employee, Name); |
|
||||||||||
|
示例中所使用的数据:
Employees:
LOAD * inline [
Employee|ID|Salary
Bill|001|20000
John|002|30000
Steve|003|35000
] (delimiter is '|');
Citizens:
Load * inline [
Name|Address
Bill|New York
Mary|London
Steve|Chicago
Lucy|Paris
John|Miami
] (delimiter is '|');
EmployeeAddresses:
Load Name as Employee, Address Resident Citizens where Exists (Employee, Name);
Drop Tables Employees, Citizens;