TABLES create table customer( cid number(4) primary key, cname varchar(12) not null, csurname varchar(12) not null, cadress varchar(12) not null, cphone number(8) not null) ; create table staff( sid number(4) primary key, sname varchar(12), ssurname varchar(12), sadress varchar(12), sposition varchar(12), sphone number(8), salary number(8)) ; create table insurance( insid number(4) primary key, year_from number(4) not null, year_to number(4) not null, cid number(4) references customer, sid number(4) references staff, price number(12) not null) ; create table car( carid number(4) primary key, car_brand varchar(12) not null, car_colour varchar(12) not null, cid number(4) references customer) ; create table recent_customers( cid number(4) not null, cname varchar(12) not null, csurname varchar(12) not null, cadress varchar(12) not null, cphone number(8) not null) ; create table SAL( ids NUMBER(4) PRIMARY KEY , losal NUMBER(7,2) not null, hisal NUMBER(7,2) not null, position varchar2(12) not null ); ##################################################################################### TRIGGERS set serveroutput on create or replace trigger ChangeCust after delete on customer for each row begin insert into recent_customers values( :old.cid, :old.cname, :old.csurname, :old.cadress, :old.cphone); end; / create or replace trigger AddCustomer after insert on customer begin dbms_output.put_line('A NEW CUSTOMER ADDED'); end; / create or replace trigger InsuranceIndex before insert on insurance for each row begin select nvl(max(i.insid)+1,1) into :new.insid from insurance i; end; / create or replace trigger CheckPrice before insert or update on insurance for each row begin if (:new.price < 1)then Raise_application_error(-20000,'WRONG PRICE ENTERED!'); end if; end; / create or replace trigger DontDelete before delete on insurance for each row begin Raise_application_error(-20001,'YOU CANT DELETE AN INSURANCE!!!'); end; / create or replace trigger SalUpdate after update on staff for each row begin if(:new.salary < :old.salary) then dbms_output.put_line('WARNING!!! NEW SALARY IS LOWER THAN OLD SALARY!!!'); end if; end; / ####################################################################################3 PROCEDURES create or replace procedure RaiseSalary(idin number, adding number) AS empty exception; change_grade exception; ile integer; salary integer (7,2); my_pos varchar2(20); my_losal integer; my_hisal integer; my_sal integer; BEGIN select count(*) into ile from staff where staff.sid=idin; if ile != 1 then raise empty; else select sposition,salary into my_pos,my_sal from staff where sid=idin; select s.losal, s.hisal into my_losal, my_hisal from sal s where s.position=my_pos; if my_sal+adding>my_hisal or my_sal+adding