CREATE OR REPLACE TRIGGER Bez_sekwencji
BEFORE INSERT
ON dept
FOR EACH ROW
BEGIN
  IF :NEW.deptno IS NULL THEN
    SELECT nvl(max(deptno),0)+10 INTO :NEW.deptno FROM dept;
  END IF;
END;
/

INSERT INTO dept(dname, loc) VALUES('CLEANING', 'KOZIA WOLA');
SELECT * FROM dept WHERE deptno > 40;
ROLLBACK;

DROP TRIGGER Bez_sekwencji;
