blob: 150d0d43a48e9cf9804c170615844c73b34067df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-- Stored Function
create or replace function pruef_operation(p_persnr integer, p_opnr integer)
return integer
as
v_persnr integer;
begin
select persnr into v_persnr
from operation
where opnr = p_opnr;
if v_persnr = p_persnr
then return 0;
else return 1;
end if;
end;
/
-- Trigger
create or replace trigger ASSISTENZ_INSERT
before insert on assistenz
for each row
declare
Eingabe_nicht_zulaessig exception;
pragma exception_init (Eingabe_nicht_zulaessig, -20001);
antwort integer;
begin
antwort := pruef_operation(:new.persnr,:new.opnummer);
if antwort = 0
then raise Eingabe_nicht_zulaessig;
end if;
exception
when Eingabe_nicht_zulaessig then
raise_application_error
(-20001, 'Chirurg ' || :new.persnr || ' leitet diese Operation!');
end;
/
|