Setting up relationship in prg

I need to set up a realtionship in a prg and I'm not quite sure how.

table1 has fields UID1, A, B

Table2 has fields UID1,UID3

Table3 has fields UID3,name

the relationship from 3 to 2 is 1->many

the relationship from 2 to 1 is one->one

I want to look from 3 to 1, filtered on table1.A == "aflag"

this is what I tried

USE c:\table1.DBF

SET FILTER TO A = "aflag"

INDEX on uid1 TO tmp

select 2

USE c:\table2.dbf

index on UID3 to tmp2

set relation to uid1 into table1

SELECT 3

USE R:\Abacus\law3.DBF

set relation to uid3 INTO table2

SET SKIP TO table2

BROWSE FIELDS name,table1.a,table1.b

========================================

showed all records not just filtered set.

oh, what to do

any help is appreciated

tx dh



Answer this question

Setting up relationship in prg

  • programmer2005

    browse fields .... for trim(table1.a) == "aflag"

    PS:
    1) I think all those table and column names were symbolic and not real names.
    2) You don't need to create an index each time. Create those indexes once as part of structural index.

    As Tamar already said probably it'd be better for you to use an SQL instead (I didn't understand your note about it).


  • Eric2002

    I do have to bring data back to law3 from table1

    sorry I didn't mention that.

    dh


  • thirdq

    Unless you need to modify the data, it's easier to do this sort of thing with a query than with relations.


    SELECT Name, A, B ;
    from Law3 ;
    JOIN Table2 ;
    ON Law3.UID3 = Table2.UID3 ;
    JOIN Table1 ;
    ON Table2.UID2 = Table1.UID1 ;
    WHERE Table1.A = "aflag" ;
    INTO CURSOR Result

    BROWSE

    Tamar

  • Setting up relationship in prg