Files
obsidian/WS2324/Datenbank/Unterricht/12. Trigger (09.01.2024)/Praktikum/Aufgaben.md

48 lines
575 B
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
3
a)
```SQL
CREATE OR REPLACE TRIGGER InsertLagerplatz
BEFORE INSERT ON LAGER
FOR EACH ROW
DECLARE
    anzahl INTEGER DEFAULT 0;
    nurZweiLPs EXCEPTION;
BEGIN
    if :new.anummer is NOT NULL
    THEN
        select count(*) into anzahl
        from LAGER
        where ANUMMER= :new.anummer;
        IF anzahl >=2 THEN
            RAISE nurZweiLPs;
        END IF;
    END IF;
EXCEPTION
    when  nurZweiLPs
    THEN raise_application_error(-20500, 'Es gibt bereits zwei Lagerplaetze');
END;
```
b)
```SQL
```