[comp.databases] dBase III+

ananth@mandrill.CWRU.Edu (ananth srinivasan) (04/12/88)

I have a problem with dBaseIII+ syntax and would appreciate any help.
I have two relations with join-able attributes (say ID) and I need
to find out those ID's that exist in one and don't exist in the other.
In SQL I can use the NOT EXISTS syntax; in QUEL I can use the
ANY...=0 syntax; and in Rbase V I can use the SUBTRACT operator
(which really makes the most sense). My question is what is the
appropriate syntax in dBase?

wew@naucse.UUCP (Bill Wilson) (04/19/88)

In article <2413@mandrill.CWRU.Edu>, ananth@mandrill.CWRU.Edu (ananth srinivasan) writes:
> I have a problem with dBaseIII+ syntax and would appreciate any help.
> I have two relations with join-able attributes (say ID) and I need
> to find out those ID's that exist in one and don't exist in the other.
> In SQL I can use the NOT EXISTS syntax; in QUEL I can use the
> ANY...=0 syntax; and in Rbase V I can use the SUBTRACT operator
> (which really makes the most sense). My question is what is the
> appropriate syntax in dBase?

After setting your relations up, try the following:

select 1
accept 'Enter ID: ' to ID
seek ID
select 2
if eof()
  ? 'That ID is not in the second database.'
endif

This assumes that ID is a character field and that the files
are indexed on ID for both.

If you hve any other problems feel free to contact me.  I have
some friends that do custom dBASE work if you have any good
sized projects.

Bill Wilson
602-523-6461
Bitnet: ucc2wew@nauvm

steve@violet.berkeley.edu (Steve Goldfield) (04/19/88)

In article <2413@mandrill.CWRU.Edu> ananth@mandrill.CWRU.Edu (ananth srinivasan) writes:
#>I have a problem with dBaseIII+ syntax and would appreciate any help.
#>I have two relations with join-able attributes (say ID) and I need
#>to find out those ID's that exist in one and don't exist in the other.
#>In SQL I can use the NOT EXISTS syntax; in QUEL I can use the
#>ANY...=0 syntax; and in Rbase V I can use the SUBTRACT operator
#>(which really makes the most sense). My question is what is the
#>appropriate syntax in dBase?

Unless you have a feature I don't know about with the plus,
all you can do in dBase is to index both files and then loop
through each doing a find on the other.

steve@violet.berkeley.edu (Steve Goldfield) (04/19/88)

In article <640@naucse.UUCP> wew@naucse.UUCP (Bill Wilson) writes:
#
#After setting your relations up, try the following:
#
#select 1
#accept 'Enter ID: ' to ID
#seek ID
#select 2
#if eof()
#  ? 'That ID is not in the second database.'
#endif
#
#This assumes that ID is a character field and that the files
#are indexed on ID for both.

I suspect that the above isn't what the questioner wanted.
Instead try (I'm assuming that dBASE III+ syntax is
similar to that of McMax).

select 1
Do while .not. eof()
  store id to idvar
  select 2
  find &idvar
  if .not. found()
    set print on
    ? idvar,' not in second database'
    set print off
  endif
  select 1
  skip
enddo
select 2
do while .not. eof()
  store id to idvar
  select 1
  find &idvar
  if .not. found()
    set print on
    ? idvar, ' not in first database'
    set print off
  endif
  select 2
  skip
enddo
set print on
  eject
set print off

ambrose@iris.ucdavis.edu (Paul Ambrose) (04/20/88)

In article <640@naucse.UUCP> wew@naucse.UUCP (Bill Wilson) writes:
>In article <2413@mandrill.CWRU.Edu>, ananth@mandrill.CWRU.Edu (ananth srinivasan) writes:
>> I have a problem with dBaseIII+ syntax and would appreciate any help.
>> I have two relations with join-able attributes (say ID) and I need
>> to find out those ID's that exist in one and don't exist in the other.
>> In SQL I can use the NOT EXISTS syntax; in QUEL I can use the
>> ANY...=0 syntax; and in Rbase V I can use the SUBTRACT operator
>> (which really makes the most sense). My question is what is the
>> appropriate syntax in dBase?

My DB3 is rusty, but I know the following works:

Given two tables, A and B, you can determine records in A that do not
have corresponding IDs in B by:

	select 1
	use B
	index on ID field
	select 2
	use A
	*(Index A here if desired)
	set relation on ID into B 
	list field_list_of_A for id <> B->id

The *for* condition (<>) will be true for all those 
records in A that do not have a correspponding ID's in B.  

Obviously, reversing the A's and B's will give the opposite, 
that is, all records in B and no corresponding IDs in A.

In both cases, the statement:
	list field_list_of_A for id = B->id
will give those records with IDs in both tables.

Of course, you can use count, report, label, etc., 
instead of the list statement. 

dgp@ncsc1.ATT.COM (Dennis Pelton x8876) (05/11/89)

I am helping a friend on a small SCO-Xenix system.  She wants
a beginner's book on Foxbase+ or dBase III+.  I only do 
mainframes and don't have any idea what to recommend.  Could
anyone, in good conscience, recommend such a book?

Please email, I will post a summary.

Dennis Pelton
att.com.UUCP!ncsc5!dgp