Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
what is exists and non exists function?
Hi,
Have a look at the explanation given in the Help.
exists(field [ , expression ] )
Determines whether a specific field value exists in a specified field of the data loaded so far. Field is a name or a string expression evaluating to a field name. The field must exist in the data loaded so far by the script. Expr is an expression evaluating to the field value to look for in the specified field. If omitted, the current record’s value in the specified field will be assumed.
Examples:
exists(Month, 'Jan') returns -1 (true) if the field value 'Jan' is found in the current content of the field Month.
exists(IDnr, IDnr) returns -1 (true) if the value of the field IDnr in the current record already exists in any previously read record containing that field.
exists (IDnr) is identical to the previous example.
Load Employee, ID, Salary from Employees.csv;
Load FirstName& ' ' &LastName as Employee, Comment from Citizens.csv where exists (Employee, FirstName& ' ' &LastName);
Only comments regarding those citizens who are employees are read.
Load A, B, C, from Employees.csv where not exists (A);
This is equivalent to performing a distinct load on field A.
Regards,
Kaushik Solanki
Hi Shivali,
Exists is used in scripting, please check below example
Table1:
ID
A
B
C
Table2:
ID
A
B
D
LOAD
*
FROM Table1; -- Loads all records in Table1
Scenario 1: Exists
LOAD
*
FROM Table2
WHERE Exists(ID); // Loads only A and B, because those values are already in Table1 and D is not loaded.
Scenario 2: Not Exists
LOAD
*
FROM Table2
WHERE Not Exists(ID); // Loads only, it is inverse of Exists.
Hope this helps you.
Regards,
Jagan.