Files
obsidian/WS2324/Datenbank/testing.sql

16 lines
401 B
SQL

create or replace trigger vor_insert_bestellposition
before insert on BESTELLPOSITION
for EACH ROW
declare
new_preis number;
var_anzahl number;
BEGIN
SELECT SUM(COUNT(*)) into var_anzahl, ARTIKELNUMMER
from BESTELLPOSITION
WHERE ARTIKELNUMMER = :new.ARTIKELNUMMER
group by ARTIKELNUMMER;
IF var_anzahl > 5 THEN
:new.reduktion := :new.preis * 0.1;
end if;
end;