
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
EXISTS() and LOOKUP?
Hi,...
Please anyone can explain...
what is Main purpose of EXISTS function?
and LOOKUP() ?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
are you preparing for some kind of exam? That's quite a abstract and general question, so I give you a general answer:
If you hit F1, this will open the HELP in QV desktop:
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.
lookup( fieldname, matchfieldname, matchfieldvalue [, tablename] )
Returns the value of fieldname corresponding to the first occurrence of the value matchfieldvalue in the field matchfieldname.
Fieldname, matchfieldname and tablename must be given as strings (e.g. quoted literals).
The search order is load order unless the table is the result of complex operations such as joins, in which case the order is not well defined.
Both fieldname and matchfieldname must be fields in the same table, specified by tablename. If tablename is omitted the current table is assumed.
If no match is found, null is returned.
Example:
lookup('Price', 'ProductID', InvoicedProd, 'pricelist')
Also searching the forum (search entry field at the top right) should return you lots of useful examples.
Regards,
Stefan


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would recommend to go to Help - Contents index and search for these two functions, since they are well explained there.
In short words EXISTS is used to limit a table load, based on loaded data in the script so far.
LOOKUP is used to look up a fieldvalue based on a matching field.
br
Paul
