Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Trigger
You can try to replace your trigger by trigger "before insert or update". In
this case your table will be read before your record come, but you need to
remake calculations to be sure that the old value of "sum" + your new value
is not more than 100.
"Stefan Poschenrieder" <stefanp_at_raysono.com> a écrit dans le message news:
3BEC0DB1.8F795A01_at_raysono.com...
> Hi,
>
> I'd like to make a trigger on a table which shall check, on any update
> and insert
> if the sum of all values of a specific column is below 100
> i did it like this:
>
> but if i do an update i get the error "trigger is not allowed to see the
> data because it the data is
> just being modified" .. can i solve this problem with a "trigger" ? the
> trigger has to read the same data
> in the table, but is not allowed to do so... any idea ?
>
>
> declare
> var_gewichtung number;
> begin
>
> select nvl(sum(GEWICHTUNG),0) into var_gewichtung from
> PORTFOLIOZUSAMMENSETZUNG
> WHERE ID_PORTFOLIO = :new.id_portfolio;
>
>
> if var_gewichtung + :new.gewichtung > 100 then
> var_gewichtung := 100 - var_gewichtung;
> raise_application_error(-20000, 'Die Summe aller Gewichtungen zu
> diesem Portfolio ist größer als 100. Bitte geben Sie einen Wert <= ' ||
> var_gewichtung || ' ein.');
> end if;
>
>
> end;
>
Received on Sat Nov 10 2001 - 02:41:44 CST
![]() |
![]() |