Subject | Re: preventing orphaned rows |
---|---|
Author | dtrudgett |
Post date | 2002-02-17T04:26:25Z |
Duilio Foschi wrote:
it. You might want to pursue it on the IBO list.
detail row from being deleted, so that there will always be at least
one detail row).
that's not what you want :-).
You could also arrange the database security so that only a particular
stored procedure has the required permissions to delete from the
detail table. That procedure would make any necessary checks before
doing the actual deletion.
The other consideration is to ask yourself why you need one or more
detail rows instead of zero or more. It might be because you have
things in the header that should be in a detail row or vice versa.
Ciao,
David Trudgett
> >Have you thought of inserting a detail row from within an AFTER INSERTPerhaps... I suppose it may depend on the approach you're taking with
> >trigger on the master table?
>
> >Alternatively, insert both the master row
> >and the first detail row using a stored procedure that first does the
> >master, then the detail.
>
> cool, but both solutions look difficult to implement with IBO, that I am
> using.
it. You might want to pursue it on the IBO list.
> >Similarly, you could use a BEFORE DELETE trigger on the detail tableYes, but my suggestion was for the reverse case (to prevent the last
> >to make sure at least one detail row remains for the master row.
>
> there is already a foreign key in the detail table that prevents the master
> to be deleted first.
detail row from being deleted, so that there will always be at least
one detail row).
>Quite true. That could be handy in some situations, but I assume
> If I apply the control you suggest, it seems that nobody will be able to
> delete a whole (master-detail) record any more...
that's not what you want :-).
You could also arrange the database security so that only a particular
stored procedure has the required permissions to delete from the
detail table. That procedure would make any necessary checks before
doing the actual deletion.
The other consideration is to ask yourself why you need one or more
detail rows instead of zero or more. It might be because you have
things in the header that should be in a detail row or vice versa.
>E poi avrai la possibilita' di dormire? ;-)
> >Come va il progetto?
>
> spero di consegnare gran parte della nuova versione gia' lunedi'.
Ciao,
David Trudgett