Wiki Home

Scan Through Result Of Relation ?

Namespace: Wiki
I've set up relations for use in a form in vfp7.

When the user presses a button on the form, I need to process all the records that are the result of the relation. Not all the records in the table, just the one's that apply to the parent table.

SCAN ... ENDSCAN doesn't seem to care about the relation, niether does GO TOP.

I'm doing
SELECT child

     ? "This Prints Too Many Times"

How can I process each of these records while still keeping the related tables up to speed?
SET SKIP TO {childAlias}
DO WHILE Parent.Value = {some saved value}

Answer #2: As everyone else has said, don't do this. Use views. -- Ted Roche

How about
SELECT child
SCAN WHILEid=Parent.Id
     ? "This Prints Too Many Times"

Or, why not use a parameterized view for the child table? Then, you can just SCAN...ENDSCAN the child view. Chad Bourque
See "Consider Using Views" under VFP Rookie Mistakes -- Randy Jean
I'm with Chad and Randy - relations, as implimented in VFP, are the most bass ackward things I've seen in the product. - William Fields

Call me old fashioned, but a SET FILTER or SCAN FOR, in this instance, is probably a much better idea than a parameterized view. -- Mike Helland

I agree with Mike here - a SCAN FOR is easy enough. Depends on how much you're using the results - if you're only doing the SCAN on it, then a parametized view is more work than it's worth - if you actually need to do several other things, then a parametized view might be worth the effort. -- Peter Crabtree

A parameterised view ensures your development is geared towards upsizing and/or multiple backends- an increasingly important consideration. Well Worth the few minutes needed to create the view. -- John Ryan

John, I disagree. Taking several minutes to rewrite a portion of an application (include adding several layers of sophistication) that will achieve the exact same thing as a single SET FILTER TO command is NOT well worth the time if it will only lead to fragmentation of the archeticture through out the application and confusion for further maintence. -- Mike Helland

I'm sure there are ways to work around the un-intuitive nature of relations, but after banging my head on a brick wall for a few years with all the (IMO) wierd behaviors of relations, I avoid them like the plague and gladly use parameterized views. Just one of the very few things I've shut the door on and never looked back. - William Fields

In my view, there is nothing simpler than relations once you wrap your head around them. All a relation basically is is telling VFP to do a SEEK every time you move the record pointer in the parent table. As for paramaterized views, if upsizing will ever matter, or if you are doing a lot of work with that table, a paramaterized view is worth it. -- Peter Crabtree
Category Open Questions
( Topic last updated: 2003.01.08 06:39:04 PM )