Re: Prevent master record without detail records
Date: 2000/01/08
Message-ID: <856459$m75$1_at_nnrp1.deja.com>#1/1
Dinis,
Expanding on my previous reply, I would guess your detail block
contains a 'quantity ordered' item for each detail record. You can
create either a GLOBAL variable, or a control block with an numeric
item to use as a counter. For each new master record, set the counter
to 0. For each detail record, increment the counter by the quantity
ordered. Then in a PRE-INSERT trigger on your master block, check that
the counter is > 0 if it is, insert the master record and the
associated detail record(s), otherwise create a MESSAGE or an ALERT to
let the user know what is happening an RAISE Form_Trigger_Failure to
abort the insert of the itemless order. You could also give them a
choice at this point either correct the order by adding one or more
items, or to cancel the order. You should also consider adding some
item level validation checking on the detail block to prevent a case
where the detail exists but is unacceptable.
Hope this helps,
Paul
In article <852rgk$319$1_at_news.fe.up.pt>,
"Dinis Paes" <dmp_at_gist.fe.up.pt> wrote:
>
> Leo Van Nieuwenhuyse <leo.van.nieuwenhuyse_at_pandora.be> wrote
> in message
> news:Ik5d4.160$SC2.2059_at_afrodite.telenet-ops.be...
> > Did I read right?
> > This is impossible in a relational model: The master must
exist before the
> > detail can be made.
> > Can you explain your problem a little bit more in detail?
>
> Hello,
>
> For instance, suppose you have a master block with customer
> orders
> and a detail block with items for each order. I want to warn
> the user
> if he/she tries to commit an order with no items.
>
> Dinis
>
> > > I've a form with two blocks: a master and a detail.
> > > I'd like to prevent the creation of master records
> > > for which no detail records were defined.
> > > What's the best way to achieve this?
> > >
> > > We're using:
> > > Forms [32 Bit] Version 6.0.5.31.0 (Production)
> > > Oracle8 Enterprise Edition Release 8.0.4.0.0 -
Production
> > >
> > >
> > > Thanks for your time,
> > >
> > > Dinis
> > >
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Jan 08 2000 - 00:00:00 CET