16 Mayıs 2019 Perşembe

CREATE TRIGGER

Örnek
Şöyle yaparız.
CREATE TABLE x (i NUMBER(10));

CREATE TRIGGER x_int_trg
 BEFORE INSERT OR UPDATE ON x
 REFERENCING NEW AS new
 FOR EACH ROW
  BEGIN
   IF :new.i NOT BETWEEN -2147483648 AND 2147483647 THEN
    raise_application_error(-20000, 'Not a 32 bit integer');
  END IF;
END x_int_trg;
/
Örnek
Şöyle yaparız.
CREATE OR REPLACE TRIGGER SYS.LOGON_TRIGGER
  AFTER LOGON ON DATABASE
DECLARE
  THIS_USER VARCHAR2(50);
BEGIN
  SELECT OSUSER INTO THIS_USER FROM V$SESSION WHERE SID = SYS_CONTEXT('USERENV','SID');
  IF THIS_USER NOT IN (<List of Users>)
    THEN RAISE LOGIN_DENIED;
  ENDIF;
END;
/