-- Add/modify columns 
alter table SYSTEM_USERS add failed_login_attempts number(2);

insert into SYSTEM_CONFIGURATION (syco_id, parameter, value, description)
values (179, 'G_PASSWORD_FAILED_LOGINS', '3', 'The number of failed logins allowed due to an invalid password');

insert into MODULE_TEXT (mtxt_id, text_number, text, language)
values (21735, 3965, 'Invalid password. <p1> attempts remaining.', 'EN');
insert into MODULE_TEXT (mtxt_id, text_number, text, language)
values (21736, 3966, 'Invalid Password. 0 attempts remaining. Account locked.', 'EN');

CREATE OR REPLACE TRIGGER SYSTEM_USERS_BU_TRIG
BEFORE UPDATE OF user_locked ON system_users
FOR EACH ROW
DECLARE
BEGIN
  IF :OLD.user_locked = 'Y'
  AND :NEW.user_locked = 'N'
  THEN
    :NEW.failed_login_attempts := 0;
  END IF;
END;
/
ALTER TRIGGER SYSTEM_USERS_BU_TRIG ENABLE;
