- 建立
- 指令碼語法和圖表函數
- 指令碼和圖表運算式中的函數
- 記錄間函數
- Exists - 指令碼函數
Exists - 指令碼函數
Exists() 會判定特定欄位值是否已載入資料載入指令碼的欄位中。該函數會傳回
Syntax:
Exists(field_name [, expr])
Return data type: 布林
Arguments:
引數 | 描述 |
---|---|
|
名稱或評估為欄位名稱的字串運算式。此欄位必須存在於指令碼到目前為止載入的資料中。 |
|
用於評估透過 field-name 所指定欄位搜尋的欄位值的運算式。如果省略,會採用指定欄位中目前記錄的值。 |
範例 | 結果 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Exists (Employee) |
如果目前記錄中欄位 Employee 的值已經存在於任何先前讀取的記錄 (包含該欄位) 中,則會傳回 -1 ( |
||||||||||
Exists(Employee, 'Bill') |
如果欄位值 'Bill' 被發現位於欄位 Employee 的目前內容中,則會傳回 -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; |
|
||||||||||
使用 where not Exists 取代之前範例中樣本資料內的陳述式,該陳述式建置了含有如下項的表格 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;