Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: SQL  |  size: 0.94 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CREATE TRIGGER reminder BEFORE UPDATE ON glpi_computers
  2.  FOR EACH ROW BEGIN
  3.   DECLARE previous_user_name VARCHAR(255);
  4.   DECLARE current_user_name VARCHAR(255);
  5.   DECLARE serial_number VARCHAR(255);
  6.   DECLARE inventory_number VARCHAR(255);
  7.   DECLARE current_host_name VARCHAR(255);
  8.   DECLARE previous_user_id VARCHAR(255);
  9.   DECLARE current_user_id VARCHAR(255);
  10.  
  11.   SET previous_user_id = OLD.users_id;
  12.   SET current_user_id = NEW.users_id;
  13.   SET previous_user_name = (SELECT name FROM glpi_users WHERE id = OLD.users_id);
  14.   SET current_user_name = (SELECT name FROM glpi_users WHERE id = NEW.users_id);
  15.   SET serial_number = OLD.serial;
  16.   SET inventory_number = OLD.otherserial;
  17.   SET current_host_name = OLD.name;
  18.  
  19.  
  20.   IF (previous_user_id != current_user_id OR current_user_id = '0') THEN
  21.    INSERT INTO glpi.logs VALUES(NULL,previous_user_name,current_user_name,serial_number,inventory_number,current_host_name,NOW());
  22.   END IF;
  23. END
  24.  
  25. |