AnsweredAssumed Answered

Count related records with local variables

Question asked by argasoft on Jan 11, 2015
Latest reply on Jan 11, 2015 by philmodjunk

Title

Count related records with local variables

Post

Hi!

In my DB I'd like to have a script that checks related records missing and lists them. There can be missing records, as I have made imports from different .xls files. Thus one table contains 8100 records and the related one 8093.

I want to make it flexible, i.e. no hard-coding of table and field names.

So I do:
- create an array $$arrtables containing all the DB-tables
- Loop through $$arrtables and create $relationlist with RelationInfo ( $$arrtables[$n] )
- Loop through $relationlist to create $relation when I find $relationlist element value containing "::"

In my thoughts now I should:
- go to $$arrtables[$n] & "List" layout
- show all records
- Loop through each record
- if [not Count ( $relation ) ] create a new record in the RelateErr table for listing

Is the whole very cumbersome (I know it will take time to fulfil the script as I have, actually 02 tables with approx. 8000 records each, but a progress bar can be visualized)?

The only faster solution I can think of is to have a calculated field in each table that contains the number of related records. So I could just look for EQ 0 here and save to RelateErr table for listing.

But how can the whole be "flexible" as a table can have more than one relationship and so what would the parameter for the RelationInfo function be in this case?

Hope it's clear.

TIA for any advice.
Arnaldo

Outcomes