Re: Inverse Master/Detail relations

Andreas Fromm <[email protected]>
Newsgroups gmane.comp.gnu.enterprise.general
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Thompson wrote:

> For existing records I don't see any problem using forms standard
> master/detail. Just still use the customer table as the master.
> Forms doesn't map master/detail to any type of primary/foreign key
> relationship in the backend. Instead master/detail simple says if
> the master changes update the detail blocks to reflect the proper
> values. So in that case I don't see an issue.
>
> Thinking it through I guess new records would cause a problem as I
> believe the master is always inserted before the details. In these
> cases you would have to fall back to triggers to populate the key
> fields prior to committing the data.
>
> I *think* something like this should do it if you're using a db
> that supports sequences.
>
> <trigger type="PRE-INSERT" name="fldAddress"><![CDATA[ # Set
> default value if self.isEmpty():
> self.autofillBySequence('seq_address_id') ]]></trigger>
>
> But I don't have a working form with this logic so it may need a
> little work to make it happy.
>
> Hope this helps, James

Thank you for your replay. With your suggestion I can insert new
records now! When I tryed to set the M/D things up, I got some strange
problems, but I think I did something wrong that time. My problem now
is that I had to delete the referencing constrain on the column, to
allaw the master record to be stored before the detail record.

Can I execute the insertion of the detail record from the trigger, so
that the referencing constrain can be left in the database?

Another question about dropdown boxes. Can I set up a dropdown or a
list box which doesn't offer the a blank entry as an option?

Regards

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDAl7JUmBtSMq5cGURAkNAAJsGAq1MlyldUsWcYVPaCjGJr+xz5QCghf/P
MuBIH85fKSXnWGR5w38sDQs=
=tk/e
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.