Subject Re: Masterlinks demo - does not work ?
Author SLSolutions@aol.com
--- In IBObjects@egroups.com, "Jason Wharton" <jwharton@i...> wrote:
> > Trying to learn about masterlinks. Want to set up master table
with
> > links to several other detail tables. Some detail tables will
only
> > have one record linked, other could have multiple records linked.
> > When I delete entry from master table want all detail records
also to
> > be deleted. As far as I can tell, masterlinks demo should do this
> > but when I try to delete a record from the master table I get an
> > error about Violation of Foreign Key Constraints.
> >
> > Can someone point me in the right direction to learn how to
> > accomplish this.
>
> Change the referential integrity to cascade the delete instead of
> restricting it. Also, you could use a trigger that would delete the
child
> records when the master record is being deleted.

Being new to Interbase and IBO, I may simply not understand but I can
find no way to accomplish what I need.

Initially my application ran under the BDE using Paradox tables. I
had a master table, Employee. I also had a PayControl table. The
PayControl table had a secondary (non unique) index by EmployeeNumber
since each employee could have any number of pay control records.

When I deleted the master (Employee) record, since the tables were
linked master/detail, all I had to do was
With PayControlTable Do
Begin
First;
While Not Eof Do
Delete;
End;
and all pay control records for the employee were deleted.

I then converted the application to Interbase using IBX. With no
change to the logic, all worked fine.

I have now converted to IBO but since I can find no where to have IBO
use a secondary index, the logic no longer works. I get a multiple
records deleted error.

I have tried to use Foreign keys to set up referential integrity but,
If I userstand correctly, the keys must be unique. Since the
PayControl table contains non unique keys, I can't see how to make
this work.

Can you assist in a more detailed explanation as to how to handle a
delete situation like mine.

Joe



>
> HTH,
> Jason Wharton
> CPS - Mesa AZ
> http://www.ibobjects.com