|
|
delete unrelated records
Hello,
Is there a way to delete records in a table that are not related to any
other record in the database? I've just gone through and "unlinked" a
bunch of records and would like to delete them. Is there any sort of
"Find Unrelated" function?
Thanks for any tips you can offer.
Sadie
|
|
0
|
|
|
|
Reply
|
sadiewms (8)
|
3/20/2006 8:36:02 PM |
|
In <1142886962.903024.297530@j33g2000cwa.googlegroups.com> Sadie wrote:
> Hello,
>
> Is there a way to delete records in a table that are not related to
> any other record in the database? I've just gone through and
> "unlinked" a bunch of records and would like to delete them. Is there
> any sort of "Find Unrelated" function?
>
> Thanks for any tips you can offer.
>
> Sadie
>
>
WHat you might do is create a calculation that would return a value if a
relationship exists:
Flag = If ( ThisTable::Key = ThatTable::Key ; 1 ; 0 )
Search Flag for <1 and you have your unrelated records.
Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
3/21/2006 12:27:40 AM
|
|
If you first perform a find related and then find omitted you have what you
need
(find related is a script function)
Ursus
"Sadie" <sadiewms@gmail.com> schreef in bericht
news:1142886962.903024.297530@j33g2000cwa.googlegroups.com...
> Hello,
>
> Is there a way to delete records in a table that are not related to any
> other record in the database? I've just gone through and "unlinked" a
> bunch of records and would like to delete them. Is there any sort of
> "Find Unrelated" function?
>
> Thanks for any tips you can offer.
>
> Sadie
>
|
|
0
|
|
|
|
Reply
|
ursus
|
3/21/2006 12:29:46 AM
|
|
In article <441f4904$0$17573$dbd43001@news.wanadoo.nl>,
secret@nowhere.com says...
> If you first perform a find related and then find omitted you have what you
> need
>
> (find related is a script function)
Er.. that should be clarified, as it only works in new versions of FM.
Basically you'd have to:
1) Find all records in parent table (on layout for parent table)
2) goto related records on a child table on a layout for child table
(show only related reocrds, show related records for all records in
found set.)
3) show omitted
4) delete all
In older versions of FM this won't work because you don't have the 2nd
option for "Goto related records".
-------
A simpler way would be to just go directly to the child table/layout,
drag the key field from the related parent table onto it, and then:
1) find mode, asterisk in the parent key field, perform find
2) show omitted
3) delete all
Like the goto related records method, this finds all the records that
are related and then inverts the found set to show all the records that
aren't. Except that it works in all versions of FM from 3 to 8.
|
|
0
|
|
|
|
Reply
|
42
|
3/21/2006 2:50:04 AM
|
|
On Tue, 21 Mar 2006 01:29:46 +0100, ursus.kirk wrote:
> If you first perform a find related and then find omitted you have what you
> need
>
> (find related is a script function)
I don't trust this search too much. However, it may be the wrong table you
look at?
My personal approach:
in layout main of table main I have a related field related::dummy
I select all records from main (cmd-j),
goto field related::dummy,
replace all contents by "x0321" (cmd-=, I guess)
goto layout related of related,
enter find mode,
set field dummy to "x0321",
omit this search (cmd-t),
perform find
.... and will have all records which are not used within main.
I could do a find from related on any suitable field of main - however,
I had some malfunctions here where I do not trust it any longer. If
there are valuable data around, make a backup before deleting the
records. Or make sure that you have an updated index by turning indexing
off in the field definitions, than re-indexing the fields you take for
relations.
- Martin
|
|
0
|
|
|
|
Reply
|
Martin
|
3/21/2006 10:18:48 AM
|
|
|
4 Replies
216 Views
(page loaded in 0.081 seconds)
|
|
|
|
|
|
|
|
|