Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not exists command
Message
From
20/04/2002 06:46:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/04/2002 10:46:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00646918
Message ID:
00647184
Views:
13
>Hey Everyone,
>I am trying to perform a command like :
>If not Exists(select field from database where anotherfield = this)
>
>Does Foxpro have an exists command that would allow me do this? I keep getting a "Function Name is Missing" error. Am I doing this wrong? Should I be using another command to perform this? Any help would be appreciated. Thanks.

'Exists' only exists < g > in SQL.
However in VFP there are few commands\functions that behave the way you say (do not use 'this' - it's reserved for object reference) :
*-If anotherfield had an index tag on it :

if seek(thisVALUE, 'SearchTable', 'AnotherFieldTag')
  luValue = SearchTable.RequestedField
*...

*-If not (or might) check lookup()
luRetValue = 
if !empty( LOOKUP(ReturnValueFromField, thisVALUE, ;
  AnotherField [, cAnotherTagName]) ) && Found
*....

* For example current table is customer and employee table is open
* You want to know if exists an employee within the same city of customer
* City is not indexed - sequential check

select customer
if !empty(lookup(employee.emp_id,customer.city,employee.City)) && Yes
 ? employee.emp_id, employee.First_Name, employee.Last_Name

* Both functions would move the pointer in SearchTable
* this might be a disadvantage. OTOH both also work on buffered tables.

* SQL doesn't work on buffered recs
select field from SearchTable ;
 where anotherfield = thisValue ;
 into array arrField
if _Tally > 0 && Exists


* Exists in SQL is used in a different way
select * from TableA ;
 where exists ;
  (select * from TableB where TableA.SomeField = TableB.SomeField)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform