From b00c424af41e5493996a68649ba37b481b4f62bd Mon Sep 17 00:00:00 2001
From: Alejandro Gallardo Escobar <alex@artica.es>
Date: Thu, 14 May 2015 12:22:36 +0200
Subject: [PATCH] Fixed a lot of things, like the catastrophic problem with the
 sequences and the insertion triggers

---
 pandora_console/pandoradb.data.oracle.sql | 305 ++++++++++++++++++----
 pandora_console/pandoradb.oracle.sql      | 261 ++++++++++++------
 2 files changed, 434 insertions(+), 132 deletions(-)

diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql
index 437b9139bf..2b1cd379ef 100644
--- a/pandora_console/pandoradb.data.oracle.sql
+++ b/pandora_console/pandoradb.data.oracle.sql
@@ -22,11 +22,14 @@
 
 -- PL/SQL blocks must end with two semicolons because Pandora installer need it 
 
-
+--
 -- Dumping data for table talert_commands
 --
 BEGIN
 LOCK TABLE talert_commands IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_commands_inc DISABLE';
+
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (1,'eMail','Internal&#x20;type','This&#x20;alert&#x20;send&#x20;an&#x20;email&#x20;using&#x20;internal&#x20;Pandora&#x20;FMS&#x20;Server&#x20;SMTP&#x20;capabilities&#x20;&#40;defined&#x20;in&#x20;each&#x20;server,&#x20;using:&#x0d;&#x0a;_field1_&#x20;as&#x20;destination&#x20;email&#x20;address,&#x20;and&#x0d;&#x0a;_field2_&#x20;as&#x20;subject&#x20;for&#x20;message.&#x20;&#x0d;&#x0a;_field3_&#x20;as&#x20;text&#x20;of&#x20;message.',1,'[\Destination&#x20;address\",\Subject\",\Text\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (2,'Internal&#x20;Audit','Internal&#x20;type','This&#x20;alert&#x20;save&#x20;alert&#x20;in&#x20;Pandora&#x20;internal&#x20;audit&#x20;system.&#x20;Fields&#x20;are&#x20;static&#x20;and&#x20;only&#x20;_field1_&#x20;is&#x20;used.',1,'[\Description\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (3,'Pandora&#x20;FMS&#x20;Event','Internal&#x20;type','This&#x20;alert&#x20;create&#x20;an&#x20;special&#x20;event&#x20;into&#x20;Pandora&#x20;FMS&#x20;event&#x20;manager.',1,'[\Event&#x20;text\",\Event&#x20;type\",\Source\",\Agent&#x20;name&#x20;or&#x20;_agent_\",\Event&#x20;criticity\",\ID&#x20;extra\",\Tags&#x20;separated&#x20;by&#x20;commas\",\Comments\",\"\",\"\"]','[\"\",\"alert_ceased,Alert&#x20;ceased;alert_fired,Alert&#x20;fired;alert_manual_validation,Alert&#x20;manual&#x20;validation;alert_recovered,Alert&#x20;recovered;configuration_change,Configuration&#x20;change&#x20;;error,Error;critical,Monitor&#x20;Critical;normal,Monitor&#x20;Normal;going_unknown,Monitor\",\"\",\"\",\"4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning\",\"\",\"\",\"\",\"\",\"\"]');
@@ -38,6 +41,12 @@ INSERT INTO talert_commands (id, name, command, description, internal, fields_de
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (9,'SMS','sendsms&#x20;_field1_&#x20;_field2_','Send&#x20;SMS&#x20;using&#x20;the&#x20;Pandora&#x20;FMS&#x20;standard&#x20;SMS&#x20;device,&#x20;using&#x20;smstools.&#x20;&#x20;Uses&#x20;field2&#x20;as&#x20;text&#x20;message,&#x20;field1&#x20;as&#x20;destination&#x20;phone&#x20;&#40;include&#x20;international&#x20;prefix!&#41;',0,'[\Destination&#x20;number\",\Message\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (10,'Validate&#x20;Event','Internal&#x20;type','This&#x20;alert&#x20;validate&#x20;the&#x20;events&#x20;matched&#x20;with&#x20;a&#x20;module&#x20;given&#x20;the&#x20;agent&#x20;name&#x20;&#40;_field1_&#41;&#x20;and&#x20;module&#x20;name&#x20;&#40;_field2_&#41;',1,'[\Agent&#x20;name\",\Module&#x20;name\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
 INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (11,'Integria&#x20;IMS&#x20;Ticket','Internal&#x20;type','This&#x20;alert&#x20;create&#x20;a&#x20;ticket&#x20;into&#x20;your&#x20;Integria&#x20;IMS.',1,'[\Integria&#x20;IMS&#x20;API&#x20;path\",\Integria&#x20;IMS&#x20;API&#x20;pass\",\Integria&#x20;IMS&#x20;user\",\Ticket&#x20;title\",\Ticket&#x20;group&#x20;ID\",\Ticket&#x20;priority\",\Ticket&#x20;description\"]','[\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very&#x20;Serious\",\"\"]');
+INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (12,'Remote&#x20;agent&#x20;control','/usr/share/pandora_server/util/udp_client.pl&#x20;_address_&#x20;41122&#x20;&quot;_field1_&quot;','This&#x20;command&#x20;is&#x20;used&#x20;to&#x20;send&#x20;commands&#x20;to&#x20;the&#x20;Pandora&#x20;FMS&#x20;agents&#x20;with&#x20;the&#x20;UDP&#x20;server&#x20;enabled.&#x20;The&#x20;UDP&#x20;server&#x20;is&#x20;used&#x20;to&#x20;order&#x20;agents&#x20;&#40;Windows&#x20;and&#x20;UNIX&#41;&#x20;to&#x20;&quot;refresh&quot;&#x20;the&#x20;agent&#x20;execution:&#x20;that&#x20;means,&#x20;to&#x20;force&#x20;the&#x20;agent&#x20;to&#x20;execute&#x20;and&#x20;send&#x20;data',0,'[\Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
+
+-- Update curr val of sequence
+update_currval('talert_commands', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_commands_inc ENABLE';
 
 COMMIT;
 END;;
@@ -132,6 +141,9 @@ END;;
 --
 BEGIN
 LOCK TABLE tconfig_os IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tconfig_os_inc DISABLE';
+
 INSERT INTO tconfig_os VALUES (1,'Linux','Linux: All versions','so_linux.png');
 INSERT INTO tconfig_os VALUES (2,'Solaris','Sun Solaris','so_solaris.png');
 INSERT INTO tconfig_os VALUES (3,'AIX','IBM AIX','so_aix.png');
@@ -151,30 +163,23 @@ INSERT INTO tconfig_os VALUES (17, 'Router', 'Generic router', 'so_router.png');
 INSERT INTO tconfig_os VALUES (18, 'Switch', 'Generic switch', 'so_switch.png');
 INSERT INTO tconfig_os VALUES (19, 'Satellite', 'Satellite agent', 'satellite.png');
 INSERT INTO tconfig_os VALUES (20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png');
+
+-- Update curr val of sequence
+update_currval('tconfig_os', 'id_os');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tconfig_os_inc ENABLE';
+
 COMMIT;
 END;;
 
-CREATE SEQUENCE tconfig_os_s INCREMENT BY 1 START WITH 1;
-
-CREATE OR REPLACE TRIGGER tconfig_os_inc BEFORE INSERT ON tconfig_os REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tconfig_os_s.nextval INTO :NEW.id_os FROM dual; END;;
-
--- PLSQL for update curr val of sequence
-BEGIN 
-	DECLARE key_max NUMBER := 0; 
-	key_currval NUMBER := 0; 
-BEGIN 
-	SELECT MAX(id_os) INTO key_max FROM tconfig_os;
-	EXECUTE IMMEDIATE 'ALTER SEQUENCE TCONFIG_OS_S INCREMENT BY ' || key_max; 
-	SELECT TCONFIG_OS_S.NEXTVAL INTO key_currval FROM dual; 
-	EXECUTE IMMEDIATE 'ALTER SEQUENCE TCONFIG_OS_S INCREMENT BY 1'; 
-END; 
-END;;
-
 --
 -- Dumping data for table tgrupo
 --
 BEGIN
 LOCK TABLE tgrupo IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgrupo_inc DISABLE';
+
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (2,'Servers','server_database',0,0,0,'',1,'');
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (4,'Firewalls','firewall',0,0,0,'',1,'');
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (8,'Databases','database_gear',0,0,0,'',1,'');
@@ -183,6 +188,12 @@ INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (11,'Workstations','computer',0,0,0,'',1,'');
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (12,'Applications','applications',0,0,0,'',1,'');
 INSERT INTO tgrupo (id_grupo, nombre, icon, parent, propagate, disabled, custom_id, id_skin, description) VALUES (13,'Web','world',0,0,0,'',1,'');
+
+-- Update curr val of sequence
+update_currval('tgrupo', 'id_grupo');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgrupo_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -217,11 +228,20 @@ END;;
 --
 BEGIN
 LOCK TABLE tlink IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tlink_inc DISABLE';
+
 INSERT INTO tlink VALUES (1,'Pandora FMS Manual','http://wiki.pandorafms.com/?title=Pandora');
 INSERT INTO tlink VALUES (2,'Pandora FMS','http://pandorafms.com');
 INSERT INTO tlink VALUES (3,'Report a bug','{https://sourceforge.net/tracker/?func=add&amp;group_id=155200&amp;atid=794852}');
 INSERT INTO tlink VALUES (4,'Suggest new feature','http://sourceforge.net/tracker/?group_id=155200&amp;atid=794855');
 INSERT INTO tlink VALUES (5,'Module library','http://pandorafms.com/pandora/repository/en');
+
+-- Update curr val of sequence
+update_currval('tlink', 'id_link');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tlink_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -230,6 +250,9 @@ END;;
 --
 BEGIN
 LOCK TABLE tmodule_group IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tmodule_group_inc DISABLE';
+
 INSERT INTO tmodule_group VALUES (1,'General');
 INSERT INTO tmodule_group VALUES (2,'Networking');
 INSERT INTO tmodule_group VALUES (3,'Application');
@@ -239,6 +262,12 @@ INSERT INTO tmodule_group VALUES (6,'Performance');
 INSERT INTO tmodule_group VALUES (7,'Database');
 INSERT INTO tmodule_group VALUES (8,'Enviromental');
 INSERT INTO tmodule_group VALUES (9,'Users');
+
+-- Update curr val of sequence
+update_currval('tmodule_group', 'id_mg');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tmodule_group_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -265,6 +294,9 @@ END;;
 -- Identifiers 30 and 31 are reserved for Enterprise data types
 BEGIN
 LOCK TABLE ttipo_modulo IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER ttipo_modulo_inc DISABLE';
+
 INSERT INTO ttipo_modulo VALUES (1,'generic_data',0,'Generic data','mod_data.png');
 INSERT INTO ttipo_modulo VALUES (2,'generic_proc',1,'Generic boolean','mod_proc.png');
 INSERT INTO ttipo_modulo VALUES (3,'generic_data_string',2,'Generic string','mod_string.png');
@@ -285,7 +317,14 @@ INSERT INTO ttipo_modulo VALUES (22,'async_data', 6, 'Asyncronous numeric data',
 INSERT INTO ttipo_modulo VALUES (23,'async_string', 8, 'Asyncronous string data', 'mod_async_string.png');
 INSERT INTO ttipo_modulo VALUES (24,'log4x',0,'Log4x','mod_log4x.png');
 INSERT INTO ttipo_modulo VALUES (100,'keep_alive',-1,'KeepAlive','mod_keepalive.png');
+
+-- Update curr val of sequence
+update_currval('ttipo_modulo', 'id_tipo');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER ttipo_modulo_inc ENABLE';
+
 COMMIT;
+
 END;;
 
 -- Categoria field is used to segregate several types
@@ -298,7 +337,7 @@ END;;
 BEGIN
 LOCK TABLE tusuario IN EXCLUSIVE MODE;
 INSERT INTO tusuario (id_user, fullname, firstname, lastname, middlename, password, comments, last_connect, registered, email, phone, is_admin, flash_chart, language, block_size, section) VALUES
-('admin', 'Pandora', 'Pandora', 'Admin', ' ', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1, 'default', 0, 'Default');
+('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1, 'default', 0, 'Default');
 COMMIT;
 END;;
 
@@ -317,11 +356,20 @@ END;;
 --
 BEGIN
 LOCK TABLE tperfil IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tperfil_inc DISABLE';
+
 INSERT INTO tperfil VALUES (1,'Operator&#x20;&#40;Read&#41;',0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0);
 INSERT INTO tperfil VALUES (2,'Operator&#x20;&#40;Write&#41;',1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0);
 INSERT INTO tperfil VALUES (3,'Chief&#x20;Operator',1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1);
 INSERT INTO tperfil VALUES (4,'Group&#x20;coordinator',1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1);
 INSERT INTO tperfil VALUES (5,'Pandora&#x20;Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+
+-- Update curr val of sequence
+update_currval('tperfil', 'id_perfil');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tperfil_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -330,8 +378,17 @@ END;;
 --
 BEGIN
 LOCK TABLE tnews IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnews_inc DISABLE';
+
 INSERT INTO tnews (id_news, author, subject, text, timestamp) VALUES (1,'admin','Welcome to Pandora FMS 4.0','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.<br><br>The Pandora FMS Team.',current_timestamp);
 INSERT INTO tnews (id_news, author, subject, text, timestamp) VALUES (2,'admin','New Pandora FMS Agent Features','Feel free to test our new features for both Windows and Linux agents: Proxy and Broker modes.',current_timestamp);
+
+-- Update curr val of sequence
+update_currval('tnews', 'id_news');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnews_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -340,11 +397,20 @@ END;;
 --
 BEGIN
 LOCK TABLE tmodule IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tmodule_inc DISABLE';
+
 INSERT INTO tmodule VALUES (1,'Agent&#x20;module');
 INSERT INTO tmodule VALUES (2,'Network&#x20;module');
 INSERT INTO tmodule VALUES (4,'Plugin&#x20;module');
 INSERT INTO tmodule VALUES (5,'Prediction&#x20;module');
 INSERT INTO tmodule VALUES (6,'WMI&#x20;module');
+
+-- Update curr val of sequence
+update_currval('tmodule', 'id_module');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tmodule_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -353,6 +419,9 @@ END;;
 --
 BEGIN
 LOCK TABLE tnetwork_component IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_component_inc DISABLE';
+
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, wizard_level, critical_instructions, warning_instructions, unknown_instructions, tags, disabled_types_event, module_macros) VALUES (1,'OS&#x20;Total&#x20;process','Total&#x20;process&#x20;in&#x20;Operating&#x20;System&#x20;(UNIX&#x20;MIB)',13,15,0,0,300,0,'','','public','HOST-RESOURCES-MIB::hrSystemProcesses.0 ',4,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','','');
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, wizard_level, critical_instructions, warning_instructions, unknown_instructions, tags, disabled_types_event, module_macros) VALUES (2,'OS&#x20;CPU&#x20;Load&#x20;(1&#x20;min)','CPU&#x20;Load&#x20;in&#x20;Operating&#x20;System&#x20;(UNIX&#x20;MIB)',13,15,0,0,300,0,'','','public','UCD-SNMP-MIB::laLoad.1',4,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','','');
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, wizard_level, critical_instructions, warning_instructions, unknown_instructions, tags, disabled_types_event, module_macros) VALUES (3,'Sysname','Get&#x20;name&#x20;of&#x20;system&#x20;using&#x20;SNMP&#x20;standard&#x20;MIB',1,17,0,0,900,0,'','','public','.1.3.6.1.2.1.1.1.0',1,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','','');
@@ -962,6 +1031,12 @@ INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, m
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, wizard_level, critical_instructions, warning_instructions, unknown_instructions, tags, disabled_types_event, module_macros) VALUES (783,'Check&#x20;Informix&#x20;Port','',19,9,0,0,300,1526,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','','');
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, wizard_level, critical_instructions, warning_instructions, unknown_instructions, tags, disabled_types_event, module_macros) VALUES (784,'Check&#x20;port&#x20;DB2','',49,9,0,0,300,50000,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','','');
 INSERT INTO tnetwork_component (id_nc, name, description, id_group, type, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, id_module_group, id_modulo, id_plugin, plugin_user, plugin_pass, plugin_parameter, max_timeout, max_retries, history_data, min_warning, max_warning, str_warning, min_critical, max_critical, str_critical, min_ff_event, custom_string_1, custom_string_2, custom_string_3, custom_integer_1, custom_integer_2, post_process, unit, wizard_level, macros, critical_instructions, warning_instructions, unknown_instructions, critical_inverse, warning_inverse, id_category, tags, disabled_types_event, module_macros, min_ff_event_normal, min_ff_event_warning, min_ff_event_critical, each_ff) VALUES (785,'Packet&#x20;Loss','Measure&#x20;packet&#x20;loss&#x20;in&#x20;the&#x20;network,&#x20;using&#x20;a&#x20;flood&#x20;ping&#x20;&#40;50&#x20;ping&#x20;in&#x20;8&#x20;secons&#41;&#x20;and&#x20;counting&#x20;back&#x20;missing&#x20;packets.&#x20;It&#x20;should&#x20;be&#x20;zero&#x20;on&#x20;most&#x20;cases.&#x20;',10,1,0,0,300,0,'','','','',2,4,9,'','','',0,0,1,10.00,0.00,'',30.00,0.00,'',0,'','','',0,0,0.00000,'%','nowizard','{\"1\":{\macro\":\"_field1_\",\desc\":\Test&#x20;time\",\help\":\"\",\value\":\"8\",\hide\":\"\"},\"2\":{\macro\":\"_field2_\",\desc\":\Target&#x20;IP\",\help\":\"\",\value\":\"\",\hide\":\"\"}}','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;.&#x20;Aditionally,&#x20;and&#x20;due&#x20;the&#x20;major&#x20;packet&#x20;loss,&#x20;probably&#x20;you&#x20;can&#x20;see&#x20;a&#x20;simple&#x20;ping&#x20;failing&#x20;here.&#x20;Check&#x20;your&#x20;network&#x20;equipment.','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;','',0,0,0,'','{\going_unknown\":0}','',0,0,0,0);
+
+-- Update curr val of sequence
+update_currval('tnetwork_component', 'id_nc');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_component_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -970,24 +1045,27 @@ END;;
 --
 BEGIN
 LOCK TABLE tnetwork_component_group IN EXCLUSIVE MODE;
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (1,'General group',0);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (2,'Cisco MIBs',10);
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_component_group_inc DISABLE';
+
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (1,'General&#x20;group',0);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (2,'Cisco&#x20;MIBs',10);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (5,'UNIX&#x20;Systems',12);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (10,'Network Management',0);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (10,'Network&#x20;Management',0);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (11,'Microsoft&#x20;Windows',12);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (12,'Operating Systems',0);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (13,'UCD Mibs (Linux, UCD-SNMP)',12);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (12,'Operating&#x20;Systems',0);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (13,'UCD&#x20;Mibs&#x20;(Linux,&#x20;UCD-SNMP)',12);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (14,'WMI',12);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (15,'Databases',0);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (16,'Windows System',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (17,'Windows Hardware Layer',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (18,'Windows AD ',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (19,'Windows IIS ',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (20,'Windows Exchange',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (21,'Windows LDAP ',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (22,'Windows MSDTC  ',14);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (23,'Catalyst 2900  ',2);
-INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (24,'Windows Printers',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (16,'Windows&#x20;System',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (17,'Windows&#x20;Hardware&#x20;Layer',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (18,'Windows&#x20;AD',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (19,'Windows&#x20;IIS',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (20,'Windows&#x20;Exchange',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (21,'Windows&#x20;LDAP',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (22,'Windows&#x20;MSDTC',14);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (23,'Catalyst&#x20;2900',2);
+INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (24,'Windows&#x20;Printers',14);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (25,'Citrix',0);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (26,'Exchange&#x20;Services',20);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (27,'MS&#x20;SQL&#x20;Server',15);
@@ -1012,6 +1090,12 @@ INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (45,'Solaris',
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (46,'AIX',5);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (47,'BSD',5);
 INSERT INTO tnetwork_component_group (id_sg, name, parent) VALUES (48,'MacOS',0);
+
+-- Update curr val of sequence
+update_currval('tnetwork_component_group', 'id_sg');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_component_group_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -1020,9 +1104,17 @@ END;;
 --
 BEGIN
 LOCK TABLE tnetwork_profile IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_profile_inc DISABLE';
+
 INSERT INTO tnetwork_profile (id_np, name, description) VALUES (2,'Basic Monitoring','Only ICMP check');
 INSERT INTO tnetwork_profile (id_np, name, description) VALUES (3,'Basic DMZ Server monitoring','This group of network checks, checks for default services located on DMZ servers...');
 
+-- Update curr val of sequence
+update_currval('tnetwork_profile', 'id_np');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tnetwork_profile_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -1044,14 +1136,32 @@ END;;
 -- GIS
 BEGIN
 LOCK TABLE tgis_map IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_inc DISABLE';
+
 INSERT INTO tgis_map VALUES (1,'Sample',-3.708187,40.42056,0,16,'',-3.708187,40.42056,0,0,1);
+
+-- Update curr val of sequence
+update_currval('tgis_map', 'id_tgis_map');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_inc ENABLE';
+
 COMMIT;
 END;;
 
 BEGIN
 LOCK TABLE tgis_map_connection IN EXCLUSIVE MODE;
-INSERT INTO tgis_map_connection VALUES (1,'OpenStreetMap (MapQuest Open)','OSM','{\type\":\OSM\",\url\":\http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png\"}',19,16,-3.708187,40.42056,0,-3.708187,40.42056,0,0);
-INSERT INTO tgis_map_connection VALUES (2,'OpenStreetMap (Standard)','OSM','{\type\":\OSM\",\url\":\http://tile.openstreetmap.org/${z}/${x}/${y}.png\"}',19,16,-3.708187,40.42056,0,-3.708187,40.42056,0,0);
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_connection_inc DISABLE';
+
+INSERT INTO tgis_map_connection VALUES (1,'OpenStreetMap (MapQuest Open)','OSM','{"type":"OSM","url":"http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png"}',19,16,-3.708187,40.42056,0,-3.708187,40.42056,0,0);
+INSERT INTO tgis_map_connection VALUES (2,'OpenStreetMap (Standard)','OSM','{"type":"OSM","url":"http://tile.openstreetmap.org/${z}/${x}/${y}.png"}',19,16,-3.708187,40.42056,0,-3.708187,40.42056,0,0);
+
+-- Update curr val of sequence
+update_currval('tgis_map_connection', 'id_tmap_connection');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_connection_inc ENABLE';
+
 COMMIT;
 END;;
 
@@ -1059,54 +1169,81 @@ END;;
 
 --BEGIN
 --LOCK TABLE tgis_map_has_tgis_map_connection IN EXCLUSIVE MODE;
+
+--EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_has_tgis_map_connection_inc DISABLE';
+
 --INSERT INTO tgis_map_has_tgis_map_connection VALUES (1,1,'2010-03-01 09:46:48',1);
+
+--EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_has_tgis_map_connection_inc ENABLE';
+
 --COMMIT;
 --END;
 --/
 
 BEGIN
 LOCK TABLE tgis_map_layer IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_layer_inc DISABLE';
+
 INSERT INTO tgis_map_layer VALUES (1,'Group All',1,0,1,0);
+
+-- Update curr val of sequence
+update_currval('tgis_map_layer', 'id_tmap_layer');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tgis_map_layer_inc ENABLE';
+
 COMMIT;
 END;;
 
--- example alert template
-BEGIN
-LOCK TABLE talert_commands IN EXCLUSIVE MODE;
-INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (12,'Remote&#x20;agent&#x20;control','/usr/share/pandora_server/util/udp_client.pl&#x20;_address_&#x20;41122&#x20;&quot;_field1_&quot;','This&#x20;command&#x20;is&#x20;used&#x20;to&#x20;send&#x20;commands&#x20;to&#x20;the&#x20;Pandora&#x20;FMS&#x20;agents&#x20;with&#x20;the&#x20;UDP&#x20;server&#x20;enabled.&#x20;The&#x20;UDP&#x20;server&#x20;is&#x20;used&#x20;to&#x20;order&#x20;agents&#x20;&#40;Windows&#x20;and&#x20;UNIX&#41;&#x20;to&#x20;&quot;refresh&quot;&#x20;the&#x20;agent&#x20;execution:&#x20;that&#x20;means,&#x20;to&#x20;force&#x20;the&#x20;agent&#x20;to&#x20;execute&#x20;and&#x20;send&#x20;data',0,'[\Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
-COMMIT;
-END;;
 
 BEGIN
 LOCK TABLE talert_actions IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_actions_inc DISABLE';
+
 INSERT INTO talert_actions (id, name, id_alert_command, field1, field2, field3, id_group, action_threshold) VALUES (1,'Mail&#x20;to&#x20;XXX',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','',0,0);
 INSERT INTO talert_actions (id, name, id_alert_command, field1, field2, field3, id_group, action_threshold) VALUES (2,'Restart&#x20;agent',12,'REFRESH AGENT *','','',0,0);
 INSERT INTO talert_actions (id, name, id_alert_command, field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, id_group, action_threshold, field1_recovery, field2_recovery, field3_recovery, field4_recovery, field5_recovery, field6_recovery, field7_recovery, field8_recovery, field9_recovery, field10_recovery) VALUES (3,'Pandora&#x20;FMS&#x20;Event',3,'_agent_&#x20;_module_&#x20;generated&#x20;an&#x20;event&#x20;alert&#x20;&#40;_data_&#41;','alert_fired','pandora','','4','','','','','',0,0,'RECOVERED:&#x20;_agent_&#x20;_module_&#x20;generated&#x20;event&#x20;alert&#x20;&#40;_data_&#41;','alert_ceased','pandora','','4','','','','','');
 INSERT INTO talert_actions (id, name, id_alert_command, field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, id_group, action_threshold, field1_recovery, field2_recovery, field3_recovery, field4_recovery, field5_recovery, field6_recovery, field7_recovery, field8_recovery, field9_recovery, field10_recovery) VALUES (4,'Create&#x20;a&#x20;ticket&#x20;in&#x20;Integria&#x20;IMS',11,'http://localhost/integria/include/api.php','1234','admin','_agent_:&#x20;_alert_name_','1','3','_alert_description_','','','',0,0,'','','','','','','','','','');
+
+-- Update curr val of sequence
+update_currval('talert_actions', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_actions_inc ENABLE';
+
 COMMIT;
 END;;
 
 BEGIN
 LOCK TABLE talert_templates IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_templates_inc DISABLE';
+
 INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (1,'Critical&#x20;condition','This is a generic alert template to fire on condition CRITICAL',1,'','','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been fired because a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n','critical','',1,0.00,0.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,1,'[PANDORA] Alert RECOVERED for CRITICAL status on _agent_ / _module_','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been RECOVERED from a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n',4,0,0,'basic');
 INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (2,'Manual&#x20;alert','This is a template used to fire manual alerts, condition defined here never will be executed. Use this template to assign to your actions/commands used to do remote management (Agent restart, execute commands on server, etc).',NULL,'','',' ','max_min','',1,0.00,1.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,0,' ',' ',1,0,0,'basic');
 INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (3,'Warning&#x20;condition','This&#x20;is&#x20;a&#x20;generic&#x20;alert&#x20;template&#x20;to&#x20;fire&#x20;on&#x20;WARNING&#x20;condition.',1,'','','Hello,&#x20;this&#x20;is&#x20;an&#x20;automated&#x20;email&#x20;coming&#x20;from&#x20;Pandora&#x20;FMS&#x0d;&#x0a;&#x0d;&#x0a;This&#x20;alert&#x20;has&#x20;been&#x20;fired&#x20;because&#x20;a&#x20;WARNING&#x20;condition&#x20;in&#x20;one&#x20;of&#x20;your&#x20;monitored&#x20;items:&#x0d;&#x0a;&#x0d;&#x0a;Agent&#x20;:&#x20;_agent_&#x0d;&#x0a;Module:&#x20;_module_&#x0d;&#x0a;Module&#x20;description:&#x20;_moduledescription_&#x0d;&#x0a;Timestamp&#x20;_timestamp_&#x0d;&#x0a;Current&#x20;value:&#x20;_data_&#x0d;&#x0a;&#x0d;&#x0a;Thanks&#x20;for&#x20;your&#x20;time.&#x0d;&#x0a;&#x0d;&#x0a;Best&#x20;regards&#x0d;&#x0a;Pandora&#x20;FMS&#x0d;&#x0a;','warning','',1,0.00,0.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,1,'[PANDORA]&#x20;Alert&#x20;RECOVERED&#x20;for&#x20;WARNING&#x20;status&#x20;on&#x20;_agent_&#x20;/&#x20;_module_','Hello,&#x20;this&#x20;is&#x20;an&#x20;automated&#x20;email&#x20;coming&#x20;from&#x20;Pandora&#x20;FMS&#x0d;&#x0a;&#x0d;&#x0a;This&#x20;alert&#x20;has&#x20;been&#x20;RECOVERED&#x20;from&#x20;a&#x20;WARNING&#x20;condition&#x20;in&#x20;one&#x20;of&#x20;your&#x20;monitored&#x20;items:&#x0d;&#x0a;&#x0d;&#x0a;Agent&#x20;:&#x20;_agent_&#x0d;&#x0a;Module:&#x20;_module_&#x0d;&#x0a;Module&#x20;description:&#x20;_moduledescription_&#x0d;&#x0a;Timestamp&#x20;_timestamp_&#x0d;&#x0a;Current&#x20;value:&#x20;_data_&#x0d;&#x0a;&#x0d;&#x0a;Thanks&#x20;for&#x20;your&#x20;time.&#x0d;&#x0a;&#x0d;&#x0a;Best&#x20;regards&#x0d;&#x0a;Pandora&#x20;FMS&#x0d;&#x0a;',3,0,0,'basic');
+
+-- Update curr val of sequence
+update_currval('talert_templates', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER talert_templates_inc ENABLE';
+
 COMMIT;
 END;;
 
 -- treport_custom_sql Data
+-- procedure to insert more than 4000 chars into a string 
+CREATE OR REPLACE PROCEDURE treport_custom_sql_insert (IDX IN NUMBER, NAME IN VARCHAR2, SQL_TXT IN VARCHAR2, FLAG IN NUMBER := 0 ) AS g_nclob CLOB; BEGIN IF FLAG = 0 THEN INSERT INTO treport_custom_sql (id, name, sql) VALUES (IDX, NAME, empty_clob()) RETURNING sql INTO g_nclob; DBMS_LOB.write(g_nclob, length (SQL_TXT), 1, SQL_TXT); ELSE SELECT sql INTO g_nclob FROM treport_custom_sql WHERE id = IDX FOR UPDATE; DBMS_LOB.writeappend(g_nclob, length(SQL_TXT), SQL_TXT); END IF; END treport_custom_sql_insert;;
+
 BEGIN
 LOCK TABLE treport_custom_sql IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER treport_custom_sql_inc DISABLE';
+
 INSERT INTO treport_custom_sql (id, name, sql) VALUES (1, 'Monitoring&#x20;Report&#x20;Agent', 'select&#x20;direccion,&#x20;nombre,&#x20;comentarios,&#x20;&#40;select&#x20;nombre&#x20;from&#x20;tgrupo&#x20;where&#x20;tgrupo.id_grupo&#x20;=&#x20;tagente.id_grupo&#41;&#x20;as&#x20;group&#x20;from&#x20;tagente;');
 INSERT INTO treport_custom_sql (id, name, sql) VALUES (2, 'Monitoring&#x20;Report&#x20;Modules', 'select&#x20;&#40;select&#x20;tagente.nombre&#x20;from&#x20;tagente&#x20;where&#x20;tagente.id_agente&#x20;=&#x20;tagente_modulo.id_agente&#41;&#x20;as&#x20;agent_name,&#x20;nombre&#x20;,&#x20;&#40;select&#x20;tmodule_group.name&#x20;from&#x20;tmodule_group&#x20;where&#x20;tmodule_group.id_mg&#x20;=&#x20;tagente_modulo.id_module_group&#41;&#x20;as&#x20;module_group,&#x20;module_interval&#x20;from&#x20;tagente_modulo&#x20;where&#x20;delete_pending&#x20;=&#x20;0&#x20;order&#x20;by&#x20;agent_name;');
 INSERT INTO treport_custom_sql (id, name, sql) VALUES (3, 'Monitoring&#x20;Report&#x20;Alerts', 'select&#x20;t1.nombre&#x20;as&#x20;agent_name,&#x20;t2.nombre&#x20;as&#x20;module_name,&#x20;&#40;select&#x20;talert_templates.name&#x20;from&#x20;talert_templates&#x20;where&#x20;talert_templates.id&#x20;=&#x20;t3.id_alert_template&#41;&#x20;as&#x20;template,&#x20;&#40;select&#x20;group_concat&#40;t02.name&#41;&#x20;from&#x20;talert_template_module_actions&#x20;as&#x20;t01&#x20;inner&#x20;join&#x20;talert_actions&#x20;as&#x20;t02&#x20;on&#x20;t01.id_alert_action&#x20;=&#x20;t02.id&#x20;where&#x20;t01.id_alert_template_module&#x20;=&#x20;t3.id&#x20;group&#x20;by&#x20;t01.id_alert_template_module&#41;&#x20;as&#x20;actions&#x20;from&#x20;tagente&#x20;as&#x20;t1&#x20;inner&#x20;join&#x20;tagente_modulo&#x20;as&#x20;t2&#x20;on&#x20;t1.id_agente&#x20;=&#x20;t2.id_agente&#x20;inner&#x20;join&#x20;talert_template_modules&#x20;as&#x20;t3&#x20;on&#x20;t2.id_agente_modulo&#x20;=&#x20;t3.id_agent_module&#x20;order&#x20;by&#x20;agent_name,&#x20;module_name;');
-COMMIT;
-END;;
 
--- procedure to insert more than 4000 chars into a string 
-CREATE OR REPLACE PROCEDURE treport_custom_sql_insert (IDX IN NUMBER, NAME IN VARCHAR2, SQL_TXT IN VARCHAR2, FLAG IN NUMBER) AS g_nclob CLOB; BEGIN if FLAG = 0 then INSERT INTO treport_custom_sql (id, name, sql) VALUES (IDX, NAME, empty_clob()) RETURNING sql INTO g_nclob; dbms_lob.write(g_nclob, length (SQL_TXT), 1, SQL_TXT); else SELECT sql INTO g_nclob FROM treport_custom_sql WHERE id = IDX FOR UPDATE; dbms_lob.writeappend(g_nclob, length(SQL_TXT), SQL_TXT); end if; END;;
-
-BEGIN
 treport_custom_sql_insert(4, 'Group&#x20;view', 'select&#x20;t1.nombre,&#x20;&#40;select&#x20;count&#40;t3.id_agente&#41;&#x20;from&#x20;tagente&#x20;t3&#x20;where&#x20;t1.id_grupo&#x20;=',0);
 
 treport_custom_sql_insert(4, 'Group&#x20;view','&#x20;t3.id_grupo&#41;&#x20;agents,&#x20;&#40;SELECT&#x20;COUNT&#40;t4.id_agente&#41;&#x20;FROM&#x20;tagente&#x20;',1);
@@ -1166,13 +1303,37 @@ treport_custom_sql_insert(4, 'Group&#x20;view','tagente_modulo.id_agente_modulo&
 treport_custom_sql_insert(4, 'Group&#x20;view','=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;times_fired&#x20;&gt;&#x20;0&#41;&#x20;monitor_alert_fired&#x20;from&#x20;tgrupo&#x20;t1&#x20;where&#x20;0&#x20;',1);
 
 treport_custom_sql_insert(4, 'Group&#x20;view','&lt;&#x20;&#40;select&#x20;count&#40;t2.id_agente&#41;&#x20;from&#x20;tagente&#x20;t2&#x20;where&#x20;t1.id_grupo&#x20;=&#x20;t2.id_grupo&#41;',1);
+
+-- Update curr val of sequence
+update_currval('treport_custom_sql', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER treport_custom_sql_inc ENABLE';
+
 COMMIT;
 END;;
 
+BEGIN
+LOCK TABLE trecon_script IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER trecon_script_inc DISABLE';
+
 INSERT INTO trecon_script VALUES (2,'IPMI&#x20;Recon','Specific&#x20;Pandora&#x20;FMS&#x20;Intel&#x20;DCM&#x20;Discovery&#x20;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2011&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x20;./ipmi-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident_flag&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;&lt;custom_field3&gt;&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;custom_field1&#x20;=&#x20;Network&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;custom_field2&#x20;=&#x20;Username&#x0d;&#x0a;*&#x20;custom_fiedl3&#x20;=&#x20;Password','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{"1":{"macro":"_field1_","desc":"Network","help":"i.e.:&#x20;192.168.100.0/24","value":"","hide":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":"","hide":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":"","hide":"1"}}');
 INSERT INTO trecon_script VALUES (4,'SNMP&#x20;L2&#x20;Recon','Pandora&#x20;FMS&#x20;SNMP&#x20;Recon&#x20;Plugin&#x20;for&#x20;level&#x20;2&#x20;network&#x20;topology&#x20;discovery.&#x0d;&#x0a;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2014&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x0d;&#x0a;&#x0d;&#x0a;&#x20;&#x20;&#x20;./snmp-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;[custom_field3]&#x20;[custom_field4]&#x0d;&#x0a;&#x0d;&#x0a;&#x20;*&#x20;custom_field1&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;networks&#x20;&#40;i.e.:&#x20;192.168.1.0/24,192.168.2.0/24&#41;&#x0d;&#x0a;&#x20;*&#x20;custom_field2&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;snmp&#x20;communities&#x20;to&#x20;try.&#x0d;&#x0a;&#x20;*&#x20;custom_field3&#x20;=&#x20;a&#x20;router&#x20;in&#x20;the&#x20;network.&#x20;Optional&#x20;but&#x20;recommended.&#x0d;&#x0a;&#x20;*&#x20;custom_field4&#x20;=&#x20;set&#x20;to&#x20;-a&#x20;to&#x20;add&#x20;all&#x20;network&#x20;interfaces&#x20;&#40;by&#x20;default&#x20;only&#x20;interfaces&#x20;that&#x20;are&#x20;up&#x20;are&#x20;added&#41;.&#x0d;&#x0a;&#x0d;&#x0a;&#x20;Additional&#x20;information:&#x0d;&#x0a;When&#x20;the&#x20;script&#x20;is&#x20;called&#x20;from&#x20;a&#x20;recon&#x20;task&#x20;the&#x20;task_id,&#x20;group_id&#x20;and&#x20;create_incident&#x20;parameters&#x20;are&#x20;automatically&#x20;filled&#x20;by&#x20;the&#x20;Pandora&#x20;FMS&#x20;Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl','{"1":{"macro":"_field1_","desc":"Network","help":"Comma&#x20;separated&#x20;list&#x20;of&#x20;networks&#x20;&#40;i.e.:&#x20;192.168.1.0/24,192.168.2.0/24&#41;","value":"","hide":""},"2":{"macro":"_field2_","desc":"Community","help":"Comma&#x20;separated&#x20;list&#x20;of&#x20;snmp&#x20;communities&#x20;to&#x20;try.","value":"","hide":""},"3":{"macro":"_field3_","desc":"Router","help":"A&#x20;router&#x20;in&#x20;the&#x20;network.&#x20;Optional&#x20;but&#x20;recommended.","value":"","hide":""},"4":{"macro":"_field4_","desc":"Optional&#x20;parameter","help":"Set&#x20;to&#x20;-a&#x20;to&#x20;add&#x20;all&#x20;network&#x20;interfaces&#x20;&#40;by&#x20;default&#x20;only&#x20;interfaces&#x20;that&#x20;are&#x20;up&#x20;are&#x20;added&#41;.","value":"","hide":""}}');
 INSERT INTO trecon_script VALUES (5,'WMI&#x20;Recon&#x20;Script','This&#x20;script&#x20;is&#x20;used&#x20;to&#x20;automatically&#x20;gather&#x20;host&#x20;information&#x20;via&#x20;WMI.&#x0d;&#x0a;Available&#x20;parameters:&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;Network&#x20;=&#x20;network&#x20;to&#x20;scan&#x20;&#40;e.g.&#x20;192.168.100.0/24&#41;.&#x0d;&#x0a;*&#x20;WMI&#x20;auth&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;WMI&#x20;authentication&#x20;tokens&#x20;in&#x20;the&#x20;format&#x20;username%password&#x20;&#40;e.g.&#x20;Administrador%pass&#41;.&#x0d;&#x0a;&#x0d;&#x0a;See&#x20;the&#x20;documentation&#x20;for&#x20;more&#x20;information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{"1":{"macro":"_field1_","desc":"Network","help":"","value":"","hide":""},"2":{"macro":"_field2_","desc":"WMI&#x20;auth","help":"","value":"","hide":""}}');
 
+-- Update curr val of sequence
+update_currval('trecon_script', 'id_recon_script');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER trecon_script_inc ENABLE';
+
+COMMIT;
+END;;
+
+BEGIN
+LOCK TABLE tplugin IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tplugin_inc DISABLE';
+
 INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (1,'IPMI&#x20;Plugin','Plugin&#x20;to&#x20;get&#x20;IPMI&#x20;monitors&#x20;from&#x20;a&#x20;IPMI&#x20;Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{1:{macro:"_field1_",desc:Target&#x20;IP,help:"",value:""},2:{macro:"_field2_",desc:Username,help:"",value:""},3:{macro:"_field3_",desc:Password,help:"",value:""}}','-h&#x20;_field1_-u&#x20;_field2_-p&#x20;_field3_');
 INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (2,'DNS&#x20;Plugin','This&#x20;plugin&#x20;is&#x20;used&#x20;to&#x20;check&#x20;if&#x20;a&#x20;specific&#x20;domain&#x20;return&#x20;a&#x20;specific&#x20;IP&#x20;address,&#x20;and&#x20;to&#x20;check&#x20;how&#x20;time&#x20;&#40;milisecs&#41;&#x20;takes&#x20;the&#x20;DNS&#x20;to&#x20;answer.&#x20;Use&#x20;IP&#x20;address&#x20;parameter&#x20;to&#x20;specify&#x20;the&#x20;IP&#x20;of&#x20;your&#x20;domain.&#x20;Use&#x20;these&#x20;custom&#x20;parameters&#x20;for&#x20;the&#x20;other&#x20;parameters:&#x0d;&#x0a;&#x0d;&#x0a;-d&#x20;domain&#x20;to&#x20;check&#x20;&#40;for&#x20;example&#x20;pandorafms.com&#41;&#x0d;&#x0a;-s&#x20;DNS&#x20;Server&#x20;to&#x20;check&#x20;&#x20;&#40;for&#x20;example&#x20;8.8.8.8&#41;&#x0d;&#x0a;&#x0d;&#x0a;Optional&#x20;parameters:&#x0d;&#x0a;&#x0d;&#x0a;-t&#x20;Do&#x20;a&#x20;DNS&#x20;time&#x20;response&#x20;check&#x20;instead&#x20;DNS&#x20;resolve&#x20;test&#x0d;&#x0a;&#x0d;&#x0a;',15,'/usr/share/pandora_server/util/plugin/dns_plugin.sh',0,'{1:{macro:"_field1_",desc:Target&#x20;IP,help:"",value:""},2:{macro:"_field2_",desc:Domain&#x20;to&#x20;check,help:For&#x20;example&#x20;pandorafms.com,value:""},3:{macro:"_field3_",desc:DNS&#x20;Server&#x20;to&#x20;check,help:For&#x20;example&#x20;8.8.8.8,value:""},4:{macro:"_field4_",desc:Optional&#x20;parameters,help:"",value:""}}','-i&#x20;_field1_&#x20;-d&#x20;_field2_&#x20;-s&#x20;_field3_&#x20;_field4_');
 INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (3,'UDP&#x20;port&#x20;check','Check&#x20;a&#x20;remote&#x20;UDP&#x20;port&#x20;&#40;by&#x20;using&#x20;NMAP&#41;.&#x20;Use&#x20;IP&#x20;address&#x20;and&#x20;Port&#x20;options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{1:{macro:"_field1_",desc:Target&#x20;IP,help:"",value:""},2:{macro:"_field2_",desc:Port,help:"",value:""}}','-t&#x20;_field1_-p&#x20;_field2_');
@@ -1180,23 +1341,74 @@ INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, m
 INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (6,'MySQL&#x20;Plugin','Samples:&#x0d;&#x0a;&#x20;&#x20;&#x20;./mysql_plugin.sh&#x20;-u&#x20;root&#x20;-p&#x20;none&#x20;-s&#x20;localhost&#x20;-q&#x20;Com_select&#x0d;&#x0a;&#x20;&#x20;&#x20;./mysql_plugin.sh&#x20;-u&#x20;root&#x20;-p&#x20;none&#x20;-s&#x20;localhost&#x20;-q&#x20;Com_update&#x0d;&#x0a;&#x20;&#x20;&#x20;./mysql_plugin.sh&#x20;-u&#x20;root&#x20;-p&#x20;none&#x20;-s&#x20;localhost&#x20;-q&#x20;Connections&#x0d;&#x0a;&#x20;&#x20;&#x20;./mysql_plugin.sh&#x20;-u&#x20;root&#x20;-p&#x20;anypass&#x20;-s&#x20;192.168.50.24&#x20;-q&#x20;Innodb_rows_read&#x0d;&#x0a;',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{1:{macro:"_field1_",desc:IP&#x20;address,help:IP&#x20;address,value:""},2:{macro:"_field2_",desc:Username,help:Username&#x20;to&#x20;access&#x20;to&#x20;database,value:""},3:{macro:"_field3_",desc:Password,help:Password&#x20;to&#x20;access&#x20;to&#x20;database,value:""},4:{macro:"_field4_",desc:Query&#x20;string,help:Query&#x20;string&#x20;of&#x20;global&#x20;status.&#x20;For&#x20;example&#x20;&#039;Aborted_connects&#039;&#x20;or&#x20;&#039;Innodb_rows_read&#039;",value:""}}', '-s&#x20;_field1_&#x20;-u&#x20;_field2_&#x20;-p&#x20;_field3_&#x20;-q&#x20;_field4_');
 INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (8,'SNMP&#x20;remote','Plugin&#x20;that&#x20;gets&#x20;remotely,&#x20;using&#x20;SNMP,&#x20;values&#x20;such&#x20;as&#x20;the&#x20;percentage&#x20;of&#x20;disk&#x20;or&#x20;memory&#x20;used,&#x20;the&#x20;status&#x20;of&#x20;a&#x20;process&#x20;or&#x20;the&#x20;CPU&#x20;load',0,'perl&#x20;/usr/share/pandora_server/util/plugin/snmp_remote.pl',0,'{1:{macro:"_field1_",desc:Target&#x20;IP,help:"",value:"_address_"},2:{macro:"_field2_",desc:Community,help:"",value:public},3:{macro:"_field3_",desc:Plug-in&#x20;Parameters,help:Memory&#x20;use&#x20;&#40;%&#41;&#x0d;&#x0a;-m&#x20;memuse&#x0d;&#x0a;&#x0d;&#x0a;Disk&#x20;use&#x20;&#40;%&#41;&#x0d;&#x0a;-m&#x20;diskuse&#x20;-d&#x20;[disk&#x20;name]&#x0d;&#x0a;&#x0d;&#x0a;Status&#x20;of&#x20;a&#x20;process&#x20;&#40;0/1&#41;&#x0d;&#x0a;-m&#x20;process&#x20;-p&#x20;[process_name]&#x20;&#x0d;&#x0a;&#x0d;&#x0a;Average&#x20;of&#x20;CPUs&#x20;Load&#x20;&#40;%&#41;&#x0d;&#x0a;-m&#x20;cpuload,value:""}}', '-H&#x20;_field1_&#x20;-c&#x20;_field2_&#x20;_field3_');
 
+-- Update curr val of sequence
+update_currval('tplugin', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tplugin_inc ENABLE';
+
+COMMIT;
+END;;
+
+BEGIN
+LOCK TABLE tagent_custom_fields IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tagent_custom_fields_inc DISABLE';
 
 INSERT INTO tagent_custom_fields VALUES (1,'Serial&#x20;Number',0);
 INSERT INTO tagent_custom_fields VALUES (2,'Department',0);
 INSERT INTO tagent_custom_fields VALUES (3,'Additional&#x20;ID',0);
 
+-- Update curr val of sequence
+update_currval('tagent_custom_fields', 'id_field');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tagent_custom_fields_inc ENABLE';
+
+COMMIT;
+END;;
+
+
+BEGIN
+LOCK TABLE ttag IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER ttag_inc DISABLE';
+
 INSERT INTO ttag (id_tag, name, description, url, email) VALUES (1,'network','Network&#x20;equipment','http://artica.es','');
 INSERT INTO ttag (id_tag, name, description, url, email) VALUES (2,'critical','Critical&#x20;modules','','');
 INSERT INTO ttag (id_tag, name, description, url, email) VALUES (3,'dmz','DMZ&#x20;Network&#x20;Zone','','');
 INSERT INTO ttag (id_tag, name, description, url, email) VALUES (4,'performance','Performance&#x20;anda&#x20;capacity&#x20;modules','','');
 INSERT INTO ttag (id_tag, name, description, url, email) VALUES (5,'configuration','','','');
 
+-- Update curr val of sequence
+update_currval('ttag', 'id_tag');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER ttag_inc ENABLE';
+
+COMMIT;
+END;;
+
+
+BEGIN
+LOCK TABLE tevent_response IN EXCLUSIVE MODE;
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tevent_response_inc DISABLE';
+
 INSERT INTO tevent_response VALUES (1,'Ping&#x20;to&#x20;host','Ping&#x20;to&#x20;the&#x20;agent&#x20;host','ping&#x20;-c&#x20;5&#x20;_agent_address_','command',0,620,500,0,'');
 INSERT INTO tevent_response VALUES (2,'SSH&#x20;to&#x20;host','Connect&#x20;via&#x20;SSH&#x20;to&#x20;the&#x20;agent','http://192.168.70.164:8022/anyterm.html?param=_User_@_agent_address_','url',0,800,450,0,'User');
 INSERT INTO tevent_response VALUES (3,'Create&#x20;incident&#x20;from&#x20;event','Create&#x20;a&#x20;incident&#x20;from&#x20;the&#x20;event&#x20;with&#x20;the&#x20;standard&#x20;incidents&#x20;system&#x20;of&#x20;Pandora&#x20;FMS','index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;insert_form&amp;from_event=_event_id_','url',0,0,0,1,'');
 INSERT INTO tevent_response VALUES (4,'Create&#x20;Integria&#x20;IMS&#x20;incident&#x20;from&#x20;event','Create&#x20;a&#x20;incident&#x20;from&#x20;the&#x20;event&#x20;with&#x20;integria&#x20;incidents&#x20;system&#x20;of&#x20;Pandora&#x20;FMS.&#x20;&#x0d;&#x0a;&#x0d;&#x0a;Is&#x20;necessary&#x20;to&#x20;enable&#x20;and&#x20;configure&#x20;the&#x20;Integria&#x20;incidents&#x20;in&#x20;Pandora&#x20;FMS&#x20;setup.','index.php?sec=workspace&amp;sec2=operation/integria_incidents/incident&amp;tab=editor&amp;from_event=_event_id_','url',0,0,0,1,'');
 INSERT INTO tevent_response VALUES (5,'Restart&#x20;agent','Restart&#x20;the&#x20;agent&#x20;with&#x20;using&#x20;UDP&#x20;protocol.&#x0d;&#x0a;&#x0d;&#x0a;To&#x20;use&#x20;this&#x20;response&#x20;is&#x20;necessary&#x20;to&#x20;have&#x20;installed&#x20;Pandora&#x20;FMS&#x20;server&#x20;and&#x20;console&#x20;in&#x20;the&#x20;same&#x20;machine.','/usr/share/pandora_server/util/udp_client.pl&#x20;_agent_address_&#x20;41122&#x20;&quot;REFRESH&#x20;AGENT&quot;','command',0,620,500,0,'');
 
+-- Update curr val of sequence
+update_currval('tevent_response', 'id');
+
+EXECUTE IMMEDIATE 'ALTER TRIGGER tevent_response_inc ENABLE';
+
+COMMIT;
+END;;
+
+BEGIN
+LOCK TABLE tupdate_settings IN EXCLUSIVE MODE;
+
 INSERT INTO tupdate_settings VALUES ('current_update', '412');
 INSERT INTO tupdate_settings VALUES ('customer_key', 'PANDORA-FREE');
 INSERT INTO tupdate_settings VALUES ('updating_binary_path', 'Path where the updated binary files will be stored');
@@ -1212,3 +1424,4 @@ INSERT INTO tupdate_settings VALUES ('proxy_user', '');
 INSERT INTO tupdate_settings VALUES ('proxy_pass', '');
 
 COMMIT;
+END;;
diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql
index 1c59dd4242..f561762763 100755
--- a/pandora_console/pandoradb.oracle.sql
+++ b/pandora_console/pandoradb.oracle.sql
@@ -30,6 +30,9 @@ CREATE OR REPLACE FUNCTION NOW RETURN TIMESTAMP AS t_now TIMESTAMP; BEGIN SELECT
 -- Procedure for retrieve PK information after an insert statement
 CREATE OR REPLACE PROCEDURE insert_id (table_name IN VARCHAR2, sql_insert IN VARCHAR2, id OUT NUMBER ) IS v_count NUMBER; BEGIN EXECUTE IMMEDIATE sql_insert; EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM user_sequences WHERE sequence_name = ''' || table_name || '_s''' INTO v_count; IF v_count >= 1 THEN EXECUTE IMMEDIATE 'SELECT ' || table_name || '_s.currval FROM DUAL' INTO id; ELSE id := 0; END IF; EXCEPTION WHEN others THEN RAISE_APPLICATION_ERROR(-20001, 'ERROR on insert_id procedure, please check input parameters or procedure logic.'); END insert_id;;
 
+-- Procedure for update curr val of sequence
+CREATE OR REPLACE PROCEDURE update_currval (table_name IN VARCHAR2, column_name IN VARCHAR2 ) IS key_max NUMBER; BEGIN EXECUTE IMMEDIATE 'SELECT MAX(' || column_name || ') FROM ' || table_name INTO key_max; IF (key_max IS NULL) THEN key_max := 1; ELSE key_max := key_max + 1; END IF; EXECUTE IMMEDIATE 'DROP SEQUENCE ' || table_name || '_s'; EXECUTE IMMEDIATE 'CREATE SEQUENCE ' || table_name || '_s INCREMENT BY 1 START WITH ' || key_max; EXECUTE IMMEDIATE 'SELECT ' || table_name || '_s.nextval FROM dual'; END update_currval;;
+
 -- ---------------------------------------------------------------------
 -- Table `taddress`
 -- ---------------------------------------------------------------------
@@ -39,8 +42,8 @@ CREATE TABLE taddress (
 	ip_pack NUMBER(10, 0) DEFAULT 0 
 );
 CREATE INDEX taddress_ip_idx ON taddress(ip);
+
 CREATE SEQUENCE taddress_s INCREMENT BY 1 START WITH 1;
--- Triggers must end with double semicolons because Pandora installer need it 
 CREATE OR REPLACE TRIGGER taddress_inc BEFORE INSERT ON taddress REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT taddress_s.nextval INTO :NEW.id_a FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -51,6 +54,7 @@ CREATE TABLE taddress_agent (
 	id_a NUMBER(19, 0) DEFAULT 0,
 	id_agent NUMBER(19, 0) DEFAULT 0 
 );
+
 CREATE SEQUENCE taddress_agent_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER taddress_agent_inc BEFORE INSERT ON taddress_agent REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT taddress_agent_s.nextval INTO :NEW.id_ag FROM dual; END;;
 
@@ -74,12 +78,12 @@ CREATE TABLE tagente (
 	id_parent NUMBER(10, 0) DEFAULT 0,
 	custom_id VARCHAR2(255) DEFAULT '',
 	server_name VARCHAR2(100) DEFAULT '',
-	cascade_protection NUMBER(5, 0) DEFAULT 0, 
+	cascade_protection NUMBER(5, 0) DEFAULT 0,
 	--number of hours of diference with the server timezone
 	timezone_offset NUMBER(5, 0) DEFAULT 0,
-	 --path in the server to the image of the icon representing the agent
+	--path in the server to the image of the icon representing the agent
 	icon_path VARCHAR2(127) DEFAULT '',
-	 --set it to one to update the position data (altitude, longitude, latitude) whenetting information from the agent or to 0 to keep the last value and don\'t update it
+	--set it to one to update the position data (altitude, longitude, latitude) whenetting information from the agent or to 0 to keep the last value and don\'t update it
 	update_gis_data NUMBER(5, 0) DEFAULT 1,
 	url_address CLOB DEFAULT '',
 	quiet NUMBER(5, 0) DEFAULT 0,
@@ -97,6 +101,7 @@ CREATE INDEX tagente_nombre_idx ON tagente(nombre);
 CREATE INDEX tagente_direccion_idx ON tagente(direccion);
 CREATE INDEX tagente_disabled_idx ON tagente(disabled);
 CREATE INDEX tagente_id_grupo_idx ON tagente(id_grupo);
+
 CREATE SEQUENCE tagente_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tagente_inc BEFORE INSERT ON tagente REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagente_s.nextval INTO :NEW.id_agente FROM dual; END;;
 
@@ -111,6 +116,8 @@ CREATE TABLE tagente_datos (
 CREATE INDEX tagente_datos_id_agent_mod_idx ON tagente_datos(id_agente_modulo);
 CREATE INDEX tagente_datos_utimestamp_idx ON tagente_datos(utimestamp);
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- -----------------------------------------------------
 -- Table `tagente_datos_inc`
 -- -----------------------------------------------------
@@ -120,8 +127,8 @@ CREATE TABLE tagente_datos_inc (
 	utimestamp NUMBER(10, 0) DEFAULT 0
 );
 CREATE INDEX tagente_datos_inc_id_ag_mo_idx ON tagente_datos_inc(id_agente_modulo);
-CREATE SEQUENCE tagente_datos_inc_s INCREMENT BY 1 START WITH 1;
---CREATE OR REPLACE TRIGGER tagente_datos_inc_inc BEFORE INSERT ON tagente_datos_inc REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagente_datos_inc_s.nextval INTO :NEW.id_adi FROM dual; END;;
+
+-- This sequence will not work with the 'insert_id' procedure
 
 -- -----------------------------------------------------
 -- Table `tagente_datos_string`
@@ -133,6 +140,8 @@ CREATE TABLE tagente_datos_string (
 );
 CREATE INDEX tagente_datos_string_utsta_idx ON tagente_datos_string(utimestamp);
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- -----------------------------------------------------
 -- Table `tagente_datos_log4x`
 -- -----------------------------------------------------
@@ -145,6 +154,7 @@ CREATE TABLE tagente_datos_log4x (
 	utimestamp NUMBER(10, 0) DEFAULT 0
 );
 CREATE INDEX tagente_datos_log4x_id_a_m_idx ON tagente_datos_log4x(id_agente_modulo);
+
 CREATE SEQUENCE tagente_datos_log4x_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tagente_datos_log4x_inc BEFORE INSERT ON tagente_datos_log4x REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagente_datos_log4x_s.nextval INTO :NEW.id_tagente_datos_log4x FROM dual; END;;
 
@@ -176,7 +186,6 @@ CREATE INDEX tagente_estado_running_by_idx ON tagente_estado(running_by);
 CREATE INDEX tagente_estado_last_ex_try_idx ON tagente_estado(last_execution_try);
 
 CREATE SEQUENCE tagente_estado_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tagente_estado_inc BEFORE INSERT ON tagente_estado REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagente_estado_s.nextval INTO :NEW.id_agente_estado FROM dual; END;;
 
 -- Probably last_execution_try index is not useful and loads more than benefits
@@ -190,6 +199,9 @@ CREATE OR REPLACE TRIGGER tagente_estado_inc BEFORE INSERT ON tagente_estado REF
 -- 6 - WMI server
 -- 7 - WEB Server (enteprise)
 
+-- -----------------------------------------------------
+-- Table `tagente_modulo`
+-- -----------------------------------------------------
 CREATE TABLE tagente_modulo (
 	id_agente_modulo NUMBER(10, 0) PRIMARY KEY,
 	id_agente NUMBER(10, 0) DEFAULT 0,
@@ -263,11 +275,13 @@ CREATE INDEX tagente_modulo_id_t_mod_idx ON tagente_modulo(id_tipo_modulo);
 CREATE INDEX tagente_modulo_disabled_idx ON tagente_modulo(disabled);
 
 CREATE SEQUENCE tagente_modulo_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tagente_modulo_inc BEFORE INSERT ON tagente_modulo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagente_modulo_s.nextval INTO :NEW.id_agente_modulo FROM dual; END;;
 
 -- snmp_oid is also used for WMI query
 
+-- -----------------------------------------------------
+-- Table `tagent_access`
+-- -----------------------------------------------------
 CREATE TABLE tagent_access (
 	id_agent NUMBER(10, 0) DEFAULT 0,
 	utimestamp NUMBER(19, 0) DEFAULT 0
@@ -275,6 +289,11 @@ CREATE TABLE tagent_access (
 CREATE INDEX tagent_access_id_agent_idx ON tagent_access(id_agent);
 CREATE INDEX tagent_access_utimestamp_idx ON tagent_access(utimestamp);
 
+-- This sequence will not work with the 'insert_id' procedure
+
+-- -----------------------------------------------------
+-- Table `talert_snmp`
+-- -----------------------------------------------------
 CREATE TABLE talert_snmp (
 	id_as NUMBER(10, 0) PRIMARY KEY,
 	id_alert NUMBER(10, 0) DEFAULT 0,
@@ -347,9 +366,11 @@ CREATE TABLE talert_snmp (
 );
 
 CREATE SEQUENCE talert_snmp_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER talert_snmp_inc BEFORE INSERT ON talert_snmp REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_snmp_s.nextval INTO :NEW.id_as FROM dual; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_commands`
+-- -----------------------------------------------------
 CREATE TABLE talert_commands (
 	id NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '',
@@ -361,9 +382,11 @@ CREATE TABLE talert_commands (
 );
 
 CREATE SEQUENCE talert_commands_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER talert_commands_inc BEFORE INSERT ON talert_commands REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_commands_s.nextval INTO :NEW.id FROM dual; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_actions`
+-- -----------------------------------------------------
 CREATE TABLE talert_actions (
 	id NUMBER(10, 0) PRIMARY KEY,
 	name CLOB DEFAULT '',
@@ -393,12 +416,14 @@ CREATE TABLE talert_actions (
 );
 
 CREATE SEQUENCE talert_actions_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER talert_actions_inc BEFORE INSERT ON talert_actions REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_actions_s.nextval INTO :NEW.id FROM dual; END;;
 
 -- on update trigger
 CREATE OR REPLACE TRIGGER talert_actions_update AFTER UPDATE OF id ON talert_commands FOR EACH ROW BEGIN UPDATE talert_actions SET id_alert_command = :NEW.id WHERE id_alert_command = :OLD.id; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_templates`
+-- -----------------------------------------------------
 -- use to_char(time_from, 'hh24:mi:ss') function to retrieve time_from field info
 -- use to_char(time_to,   'hh24:mi:ss') function to retrieve time_to field info
 CREATE TABLE talert_templates (
@@ -454,12 +479,14 @@ CREATE TABLE talert_templates (
 CREATE INDEX talert_templates_id_al_act_idx ON talert_templates(id_alert_action);
 
 CREATE SEQUENCE talert_templates_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER talert_templates_inc BEFORE INSERT ON talert_templates REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_templates_s.nextval INTO :NEW.id FROM dual; END;;
 
 -- on update trigger
 CREATE OR REPLACE TRIGGER talert_templates_update AFTER UPDATE OF id ON talert_actions FOR EACH ROW BEGIN UPDATE talert_templates SET id_alert_action = :NEW.id WHERE id_alert_action = :OLD.id; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_template_modules`
+-- -----------------------------------------------------
 CREATE TABLE talert_template_modules (
 	id NUMBER(10, 0) PRIMARY KEY,
 	id_agent_module NUMBER(10, 0) REFERENCES tagente_modulo(id_agente_modulo) ON DELETE CASCADE,
@@ -486,6 +513,9 @@ CREATE OR REPLACE TRIGGER talert_template_modules_update AFTER UPDATE OF id_agen
 -- on update trigger 1
 CREATE OR REPLACE TRIGGER talert_template_module_update1 AFTER UPDATE OF id ON talert_templates FOR EACH ROW BEGIN UPDATE talert_template_modules SET id_alert_template = :NEW.id WHERE id_alert_template = :OLD.id; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_template_module_actions`
+-- -----------------------------------------------------
 CREATE TABLE talert_template_module_actions (
 	id NUMBER(10, 0) PRIMARY KEY,
 	id_alert_template_module NUMBER(10, 0) REFERENCES talert_template_modules(id) ON DELETE CASCADE, 
@@ -495,7 +525,7 @@ CREATE TABLE talert_template_module_actions (
 	module_action_threshold NUMBER(10, 0) DEFAULT 0,
   	last_execution NUMBER(18, 0) DEFAULT 0 
 );
-
+-- This sequence will not work with the 'insert_id' procedure
 CREATE SEQUENCE talert_template_modu_actions_s INCREMENT BY 1 START WITH 1;
 
 CREATE OR REPLACE TRIGGER talert_template_mod_action_inc BEFORE INSERT ON talert_template_module_actions REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT talert_template_modu_actions_s.nextval INTO :NEW.id FROM dual; END;;
@@ -506,6 +536,9 @@ CREATE OR REPLACE TRIGGER talert_template_mod_act_update AFTER UPDATE OF id ON t
 -- on update trigger 1
 CREATE OR REPLACE TRIGGER talert_template_mod_ac_update1 AFTER UPDATE OF id ON talert_actions FOR EACH ROW BEGIN UPDATE talert_template_module_actions SET id_alert_action = :NEW.id WHERE id_alert_action = :OLD.id; END;;
 
+-- -----------------------------------------------------
+-- Table `talert_special_days`
+-- -----------------------------------------------------
 CREATE TABLE talert_special_days (
 	id NUMBER(10,0) PRIMARY KEY,
 	id_group NUMBER(10, 0) DEFAULT 0, 
@@ -547,6 +580,7 @@ CREATE TABLE tconfig (
 	token VARCHAR2(100) DEFAULT '',
 	value CLOB DEFAULT '' 
 );
+
 CREATE SEQUENCE tconfig_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tconfig_inc BEFORE INSERT ON tconfig REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tconfig_s.nextval INTO :NEW.id_config FROM dual; END;;
 
@@ -560,6 +594,9 @@ CREATE TABLE tconfig_os (
 	icon_name VARCHAR2(100) DEFAULT ''
 );
 
+CREATE SEQUENCE tconfig_os_s INCREMENT BY 1 START WITH 1;
+CREATE OR REPLACE TRIGGER tconfig_os_inc BEFORE INSERT ON tconfig_os REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tconfig_os_s.nextval INTO :NEW.id_os FROM dual; END;;
+
 -- ---------------------------------------------------------------------
 -- Table `tevento`
 -- ---------------------------------------------------------------------
@@ -594,7 +631,6 @@ CREATE INDEX tevento_id_2_idx ON tevento(utimestamp, id_evento);
 CREATE INDEX tevento_id_agentmodule_idx ON tevento(id_agentmodule);
 
 CREATE SEQUENCE tevento_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tevento_inc BEFORE INSERT ON tevento REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tevento_s.nextval INTO :NEW.id_evento FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -620,7 +656,6 @@ CREATE TABLE tgrupo (
 );
 
 CREATE SEQUENCE tgrupo_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tgrupo_inc BEFORE INSERT ON tgrupo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgrupo_s.nextval INTO :NEW.id_grupo FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -651,7 +686,6 @@ CREATE INDEX tincidencia_id_agente_mod_idx ON tincidencia(id_agente_modulo);
 CREATE OR REPLACE TRIGGER tincidencia_actualizacion_ts BEFORE UPDATE ON tincidencia FOR EACH ROW BEGIN select CURRENT_TIMESTAMP into :NEW.actualizacion FROM dual; END;;
 
 CREATE SEQUENCE tincidencia_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tincidencia_inc BEFORE INSERT ON tincidencia REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tincidencia_s.nextval INTO :NEW.id_incidencia FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -661,6 +695,7 @@ CREATE TABLE tlanguage (
 	id_language VARCHAR2(6) DEFAULT '',
 	name VARCHAR2(100) DEFAULT ''
 );
+-- This sequence will not work with the 'insert_id' procedure
 
 -- ---------------------------------------------------------------------
 -- Table `tlink`
@@ -672,7 +707,6 @@ CREATE TABLE tlink (
 );
 
 CREATE SEQUENCE tlink_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tlink_inc BEFORE INSERT ON tlink REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tlink_s.nextval INTO :NEW.id_link FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -689,7 +723,6 @@ CREATE TABLE tmensajes (
 );
 
 CREATE SEQUENCE tmensajes_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tmensajes_inc BEFORE INSERT ON tmensajes REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmensajes_s.nextval INTO :NEW.id_mensaje FROM dual; END;;
 
 -- ---------------------------------------------------------------------
@@ -701,7 +734,6 @@ CREATE TABLE tmodule_group (
 );
 
 CREATE SEQUENCE tmodule_group_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tmodule_group_inc BEFORE INSERT ON tmodule_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmodule_group_s.nextval INTO :NEW.id_mg FROM dual; END;;
 
 -- ----------------------------------------------------------------------
@@ -715,7 +747,6 @@ CREATE TABLE tmodule_relationship (
 );
 
 CREATE SEQUENCE tmodule_relationship_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tmodule_relationship_inc BEFORE INSERT ON tmodule_relationship REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmodule_relationship_s.nextval INTO :NEW.id FROM dual; END;;
 
 -- ----------------------------------------------------------------------
@@ -777,16 +808,23 @@ CREATE TABLE tnetwork_component (
 );
 
 CREATE SEQUENCE tnetwork_component_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tnetwork_component_inc BEFORE INSERT ON tnetwork_component REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetwork_component_s.nextval INTO :NEW.id_nc FROM dual; END;;
 
+-- ----------------------------------------------------------------------
+-- Table `tnetwork_component_group`
+-- ----------------------------------------------------------------------
 CREATE TABLE tnetwork_component_group (
 	id_sg NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(200) DEFAULT '',
 	parent NUMBER(19, 0) DEFAULT 0 
 );
 
+CREATE SEQUENCE tnetwork_component_group_s INCREMENT BY 1 START WITH 1;
+CREATE OR REPLACE TRIGGER tnetwork_component_group_inc BEFORE INSERT ON tnetwork_component_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetwork_component_group_s.nextval INTO :NEW.id_sg FROM dual; END;;
 
+-- ----------------------------------------------------------------------
+-- Table `tnetwork_profile`
+-- ----------------------------------------------------------------------
 CREATE TABLE tnetwork_profile (
 	id_np NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '',
@@ -794,15 +832,22 @@ CREATE TABLE tnetwork_profile (
 );
 
 CREATE SEQUENCE tnetwork_profile_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tnetwork_profile_inc BEFORE INSERT ON tnetwork_profile REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetwork_profile_s.nextval INTO :NEW.id_np FROM dual; END;;
 
+-- ----------------------------------------------------------------------
+-- Table `tnetwork_profile_component`
+-- ----------------------------------------------------------------------
 CREATE TABLE tnetwork_profile_component (
 	id_nc NUMBER(19, 0) DEFAULT 0,
 	id_np NUMBER(19, 0) DEFAULT 0
 );
 CREATE INDEX tnetwork_profile_id_np_idx ON tnetwork_profile_component(id_np);
 
+-- This sequence will not work with the 'insert_id' procedure
+
+-- ----------------------------------------------------------------------
+-- Table `tnota`
+-- ----------------------------------------------------------------------
 CREATE TABLE tnota (
 	id_nota NUMBER(19, 0) PRIMARY KEY,
 	id_incident NUMBER(19, 0),
@@ -812,10 +857,20 @@ CREATE TABLE tnota (
 );
 CREATE INDEX tnota_id_incident_idx ON tnota(id_incident);
 
+-- This sequence will not work with the 'insert_id' procedure
+
+-- ----------------------------------------------------------------------
+-- Table `torigen`
+-- ----------------------------------------------------------------------
 CREATE TABLE torigen (
 	origen VARCHAR2(100) DEFAULT ''
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
+-- ----------------------------------------------------------------------
+-- Table `tperfil`
+-- ----------------------------------------------------------------------
 CREATE TABLE tperfil (
 	id_perfil NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(200) NOT NULL,
@@ -845,9 +900,11 @@ CREATE TABLE tperfil (
 );
 
 CREATE SEQUENCE tperfil_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tperfil_inc BEFORE INSERT ON tperfil REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tperfil_s.nextval INTO :NEW.id_perfil FROM dual; END;;
 
+-- ----------------------------------------------------------------------
+-- Table `trecon_script`
+-- ----------------------------------------------------------------------
 CREATE TABLE trecon_script (
 	id_recon_script NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '',
@@ -857,9 +914,11 @@ CREATE TABLE trecon_script (
 );
 
 CREATE SEQUENCE trecon_script_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER trecon_script_inc BEFORE INSERT ON trecon_script REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT trecon_script_s.nextval INTO :NEW.id_recon_script FROM dual; END;;
 
+-- ----------------------------------------------------------------------
+-- Table `trecon_task`
+-- ----------------------------------------------------------------------
 CREATE TABLE trecon_task (
 	id_rt NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '',
@@ -890,9 +949,11 @@ CREATE TABLE trecon_task (
 CREATE INDEX trecon_task_id_rec_serv_idx ON trecon_task(id_recon_server);
 
 CREATE SEQUENCE trecon_task_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER trecon_task_inc BEFORE INSERT ON trecon_task REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT trecon_task_s.nextval INTO :NEW.id_rt FROM dual; END trecon_task_inc;;
 
+-- ----------------------------------------------------------------------
+-- Table `tserver`
+-- ----------------------------------------------------------------------
 CREATE TABLE tserver (
 	id_server NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '',
@@ -926,7 +987,6 @@ CREATE INDEX tserver_keepalive_idx ON tserver(keepalive);
 CREATE INDEX tserver_status_idx ON tserver(status);
 
 CREATE SEQUENCE tserver_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tserver_inc BEFORE INSERT ON tserver REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tserver_s.nextval INTO :NEW.id_server FROM dual; END tserver_inc;;
 
 -- server types:
@@ -942,6 +1002,9 @@ CREATE OR REPLACE TRIGGER tserver_inc BEFORE INSERT ON tserver REFERENCING NEW A
 -- 9 web
 -- TODO: drop 2.x xxxx_server fields, unused since server_type exists.
 
+-- ----------------------------------------------------------------------
+-- Table `tsesion`
+-- ----------------------------------------------------------------------
 CREATE TABLE tsesion (
 	id_sesion NUMBER(19, 0) PRIMARY KEY,
 	id_usuario VARCHAR2(60) DEFAULT '0',
@@ -955,11 +1018,10 @@ CREATE INDEX tsesion_utimestamp_idx ON tsesion(utimestamp);
 CREATE INDEX tsesion_id_usuario_idx ON tsesion(id_usuario);
 
 CREATE SEQUENCE tsesion_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tsesion_inc BEFORE INSERT ON tsesion REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tsesion_s.nextval INTO :NEW.id_sesion FROM dual; END tsesion_inc;;
 
 -- ---------------------------------------------------------------------
--- Table ttipo_modulo
+-- Table `ttipo_modulo`
 -- ---------------------------------------------------------------------
 CREATE TABLE ttipo_modulo (
 	id_tipo NUMBER(10, 0) PRIMARY KEY,
@@ -968,11 +1030,12 @@ CREATE TABLE ttipo_modulo (
 	descripcion VARCHAR2(100) DEFAULT '',
 	icon VARCHAR2(100) DEFAULT NULL
 );
+
 CREATE SEQUENCE ttipo_modulo_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER ttipo_modulo_inc BEFORE INSERT ON ttipo_modulo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT ttipo_modulo_s.nextval INTO :NEW.id_tipo FROM dual; END ttipo_modulo_inc;;
 
 -- ---------------------------------------------------------------------
--- Table ttrap
+-- Table `ttrap`
 -- ---------------------------------------------------------------------
 CREATE TABLE ttrap (
 	id_trap NUMBER(19, 0) PRIMARY KEY,
@@ -992,6 +1055,7 @@ CREATE TABLE ttrap (
 	description VARCHAR2(255) DEFAULT '',
 	severity NUMBER(10, 0) DEFAULT 2
 );
+
 CREATE SEQUENCE ttrap_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER ttrap_inc BEFORE INSERT ON ttrap REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT ttrap_s.nextval INTO :NEW.id_trap FROM dual; END ttrap_inc;;
 
@@ -1035,6 +1099,8 @@ CREATE TABLE tusuario (
 	CONSTRAINT t_usuario_metaconsole_acc_cons CHECK (metaconsole_access IN ('basic','advanced'))
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- -----------------------------------------------------
 -- Table `tusuario_perfil`
 -- -----------------------------------------------------
@@ -1047,6 +1113,7 @@ CREATE TABLE tusuario_perfil (
 	id_policy NUMBER(10, 0) DEFAULT 0,
 	tags CLOB DEFAULT ''
 );
+
 CREATE SEQUENCE tusuario_perfil_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tusuario_perfil_inc BEFORE INSERT ON tusuario_perfil REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tusuario_perfil_s.nextval INTO :NEW.id_up FROM dual; END tusuario_perfil_inc;;
 
@@ -1058,11 +1125,12 @@ CREATE TABLE tuser_double_auth (
 	id_user VARCHAR2(60) REFERENCES tusuario(id_user) ON DELETE CASCADE,
 	secret VARCHAR2(20)
 );
+
 CREATE SEQUENCE tuser_double_auth_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_auth REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tuser_double_auth_s.nextval INTO :NEW.id FROM dual; END tuser_double_auth_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tnews
+-- Table `tnews`
 -- ---------------------------------------------------------------------
 CREATE TABLE tnews (
 	id_news NUMBER(10, 0) PRIMARY KEY,
@@ -1075,11 +1143,12 @@ CREATE TABLE tnews (
 	expire NUMBER(5, 0) DEFAULT 0,
 	expire_timestamp TIMESTAMP DEFAULT NULL
 );
+
 CREATE SEQUENCE tnews_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tnews_inc BEFORE INSERT ON tnews REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnews_s.nextval INTO :NEW.id_news FROM dual; END tnews_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tgraph
+-- Table `tgraph`
 -- ---------------------------------------------------------------------
 CREATE TABLE tgraph (
 	id_graph NUMBER(10, 0) PRIMARY KEY,
@@ -1095,11 +1164,12 @@ CREATE TABLE tgraph (
 	id_group NUMBER(19, 0) DEFAULT 0,
 	id_graph_template NUMBER(11, 0) DEFAULT 0 
 );
+
 CREATE SEQUENCE tgraph_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tgraph_inc BEFORE INSERT ON tgraph REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgraph_s.nextval INTO :NEW.id_graph FROM dual; END tgraph_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tgraph_source
+-- Table `tgraph_source`
 -- ---------------------------------------------------------------------
 CREATE TABLE tgraph_source (
 	id_gs NUMBER(10, 0) PRIMARY KEY,
@@ -1107,11 +1177,12 @@ CREATE TABLE tgraph_source (
 	id_agent_module  NUMBER(19, 0) DEFAULT 0,
 	weight BINARY_DOUBLE DEFAULT 0
 );
+
 CREATE SEQUENCE tgraph_source_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tgraph_source_inc BEFORE INSERT ON tgraph_source REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgraph_source_s.nextval INTO :NEW.id_gs FROM dual; END tgraph_source_inc;;
 
 -- ---------------------------------------------------------------------
--- Table treport
+-- Table `treport`
 -- ---------------------------------------------------------------------
 CREATE TABLE treport (
 	id_report NUMBER(10, 0) PRIMARY KEY,
@@ -1130,11 +1201,12 @@ CREATE TABLE treport (
 	metaconsole NUMBER(5, 0) DEFAULT 0,
 	non_interactive NUMBER(5, 0) DEFAULT 0
 );
+
 CREATE SEQUENCE treport_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER treport_inc BEFORE INSERT ON treport REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT treport_s.nextval INTO :NEW.id_report FROM dual; END treport_inc;;
 
 -- -----------------------------------------------------
--- Table treport_content
+-- Table `treport_content`
 -- -----------------------------------------------------
 -- use to_char(time_from, 'hh24:mi:ss') function to retrieve time_from field info
 -- use to_char(time_to,   'hh24:mi:ss') function to retrieve time_to field info
@@ -1180,12 +1252,14 @@ CREATE TABLE treport_content (
 );
 
 CREATE SEQUENCE treport_content_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER treport_content_inc BEFORE INSERT ON treport_content REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT treport_content_s.nextval INTO :NEW.id_rc FROM dual; END treport_content_inc;;
 
 -- on update trigger
 CREATE OR REPLACE TRIGGER treport_content_update AFTER UPDATE OF id_report ON treport FOR EACH ROW BEGIN UPDATE treport_content SET id_rc = :NEW.id_report WHERE id_rc = :OLD.id_report; END;;
 
+-- -----------------------------------------------------
+-- Table `treport_content_sla_combined`
+-- -----------------------------------------------------
 CREATE TABLE treport_content_sla_combined (
 	id NUMBER(10, 0) PRIMARY KEY,
 	id_report_content NUMBER(10, 0)  REFERENCES treport_content(id_rc) ON DELETE CASCADE,
@@ -1196,14 +1270,17 @@ CREATE TABLE treport_content_sla_combined (
 	server_name CLOB DEFAULT ''
 );
 
-CREATE SEQUENCE treport_cont_sla_c_s INCREMENT BY 1 START WITH 1;
+-- This sequence will not work with the 'insert_id' procedure
 
+CREATE SEQUENCE treport_cont_sla_c_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER treport_content_sla_comb_inc BEFORE INSERT ON treport_content REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT treport_cont_sla_c_s.nextval INTO :NEW.id_rc FROM dual; END treport_content_sla_comb_inc;; 
 
 -- on update trigger
 CREATE OR REPLACE TRIGGER treport_cont_sla_comb_update AFTER UPDATE OF id_rc on treport_content FOR EACH ROW BEGIN UPDATE treport_content_sla_combined SET id_report_content = :NEW.id_rc WHERE id_report_content = :OLD.id_rc; END;;
 
-
+-- -----------------------------------------------------
+-- Table `treport_content_item`
+-- -----------------------------------------------------
 CREATE TABLE treport_content_item (
 	id NUMBER(10, 0) PRIMARY KEY,
 	id_report_content NUMBER(10, 0) REFERENCES treport_content(id_rc) ON DELETE CASCADE,
@@ -1213,22 +1290,22 @@ CREATE TABLE treport_content_item (
 );
 
 CREATE SEQUENCE treport_content_item_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER treport_content_item_inc BEFORE INSERT ON treport_content_item REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT treport_content_item_s.nextval INTO :NEW.id FROM dual; END treport_content_item_inc;; 
 
 -- ---------------------------------------------------------------------
--- Table treport_custom_sql
+-- Table `treport_custom_sql`
 -- ---------------------------------------------------------------------
 CREATE TABLE treport_custom_sql (
 	id NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(150) DEFAULT '',
 	sql CLOB DEFAULT NULL
 );
+
 CREATE SEQUENCE treport_custom_sql_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER treport_custom_sql_inc BEFORE INSERT ON treport_custom_sql REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT treport_custom_sql_s.nextval INTO :NEW.id FROM dual; END treport_custom_sql_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tlayout
+-- Table `tlayout`
 -- ---------------------------------------------------------------------
 CREATE TABLE tlayout (
 	id NUMBER(10, 0) PRIMARY KEY,
@@ -1238,11 +1315,12 @@ CREATE TABLE tlayout (
 	height NUMBER(10, 0) DEFAULT 0,
 	width NUMBER(10, 0) DEFAULT 0
 );
+
 CREATE SEQUENCE tlayout_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tlayout_inc BEFORE INSERT ON tlayout REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tlayout_s.nextval INTO :NEW.id FROM dual; END tlayout_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tlayout_data
+-- Table `tlayout_data`
 -- ---------------------------------------------------------------------
 CREATE TABLE tlayout_data (
 	id NUMBER(10, 0) PRIMARY KEY,
@@ -1267,11 +1345,12 @@ CREATE TABLE tlayout_data (
 	border_color VARCHAR2(200) DEFAULT '',
 	fill_color VARCHAR2(200) DEFAULT ''
 );
+
 CREATE SEQUENCE tlayout_data_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tlayout_data_inc BEFORE INSERT ON tlayout_data REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tlayout_data_s.nextval INTO :NEW.id FROM dual; END tlayout_data_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tplugin
+-- Table `tplugin`
 -- ---------------------------------------------------------------------
 CREATE TABLE tplugin (
 	id NUMBER(10, 0) PRIMARY KEY,
@@ -1287,22 +1366,24 @@ CREATE TABLE tplugin (
 	plugin_type NUMBER(5, 0) DEFAULT 0,
 	macros CLOB DEFAULT '',
 	parameters CLOB DEFAULT ''
-); 
+);
+
 CREATE SEQUENCE tplugin_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tplugin_inc BEFORE INSERT ON tplugin REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplugin_s.nextval INTO :NEW.id FROM dual; END tplugin_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tmodule
+-- Table `tmodule`
 -- ---------------------------------------------------------------------
 CREATE TABLE tmodule (
 	id_module NUMBER(10, 0) PRIMARY KEY,
 	name VARCHAR2(100) DEFAULT '' 
 );
+
 CREATE SEQUENCE tmodule_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tmodule_inc BEFORE INSERT ON tmodule REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmodule_s.nextval INTO :NEW.id_module FROM dual; END tmodule_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tserver_export
+-- Table `tserver_export`
 -- ---------------------------------------------------------------------
 CREATE TABLE tserver_export (
 	id NUMBER(10, 0) PRIMARY KEY,
@@ -1321,9 +1402,13 @@ CREATE TABLE tserver_export (
 	timezone_offset NUMBER(5, 0) DEFAULT 0,
 	CONSTRAINT tserver_export_conn_mode_cons CHECK (connect_mode IN ('tentacle', 'ssh', 'local'))
 );
+
 CREATE SEQUENCE tserver_export_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tserver_export_inc BEFORE INSERT ON tserver_export REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tserver_export_s.nextval INTO :NEW.id FROM dual; END tserver_export_inc;;
 
+-- ---------------------------------------------------------------------
+-- Table `tserver_export_data`
+-- ---------------------------------------------------------------------
 -- id_export_server is real pandora fms export server process that manages this server
 -- id is the destination server to export
 CREATE TABLE tserver_export_data (
@@ -1337,7 +1422,6 @@ CREATE TABLE tserver_export_data (
 );
 
 CREATE SEQUENCE tserver_export_data_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tserver_export_data_inc BEFORE INSERT ON tserver_export_data REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tserver_export_data_s.nextval INTO :NEW.id FROM dual; END tserver_export_data_inc;;
 
 -- -----------------------------------------------------
@@ -1370,6 +1454,7 @@ CREATE TABLE tplanned_downtime (
 	type_periodicity VARCHAR2(100) DEFAULT 'weekly',
 	id_user VARCHAR2(100) DEFAULT '0'
 );
+
 CREATE SEQUENCE tplanned_downtime_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tplanned_downtime_inc BEFORE INSERT ON tplanned_downtime REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_s.nextval INTO :NEW.id FROM dual; END tplanned_downtime_inc;;
 
@@ -1382,6 +1467,7 @@ CREATE TABLE tplanned_downtime_agents (
 	id_downtime NUMBER(19, 0) DEFAULT 0 REFERENCES tplanned_downtime(id) ON DELETE CASCADE,
 	all_modules NUMBER(5, 0) DEFAULT 1
 );
+
 CREATE SEQUENCE tplanned_downtime_agents_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tplanned_downtime_agents_inc BEFORE INSERT ON tplanned_downtime_agents REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_agents_s.nextval INTO :NEW.id FROM dual; END tplanned_downtime_agents_inc;;
 
@@ -1394,13 +1480,14 @@ CREATE TABLE tplanned_downtime_modules (
 	id_agent_module NUMBER(10, 0) REFERENCES tagente_modulo(id_agente_modulo) ON DELETE CASCADE,
 	id_downtime NUMBER(19, 0) DEFAULT 0 REFERENCES tplanned_downtime(id) ON DELETE CASCADE
 );
+
 CREATE SEQUENCE tplanned_downtime_modules_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tplanned_downtime_modules_inc BEFORE INSERT ON tplanned_downtime_modules REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_modules_s.nextval INTO :NEW.id FROM dual; END tplanned_downtime_modules_inc;;
 
 --IS extension Tables
 
 -- -----------------------------------------------------
--- Table tgis_data_history
+-- Table `tgis_data_history`
 -- -----------------------------------------------------
 --Table to store historicalIS information of the agents
 CREATE TABLE tgis_data_history (
@@ -1426,11 +1513,10 @@ CREATE INDEX tgis_data_history_start_t_idx ON tgis_data_history(start_timestamp)
 CREATE INDEX tgis_data_history_end_t_idx ON tgis_data_history(end_timestamp);
  
 CREATE SEQUENCE tgis_data_history_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tgis_data_history_inc BEFORE INSERT ON tgis_data_history REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgis_data_history_s.nextval INTO :NEW.id_tgis_data FROM dual; END tgis_data_history_inc;;
 
 -- -----------------------------------------------------
--- Table tgis_data_status
+-- Table `tgis_data_status`
 -- -----------------------------------------------------
 --Table to store lastIS information of the agents
 --ON UPDATE NO ACTION is implicit on Oracle DBMS for tagente_id_agente field 
@@ -1461,8 +1547,10 @@ CREATE TABLE tgis_data_status (
 );
 CREATE INDEX tgis_data_status_start_t_idx ON tgis_data_status(start_timestamp);
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- -----------------------------------------------------
--- Table tgis_map
+-- Table `tgis_map`
 -- -----------------------------------------------------
 --Table containing information about ais map
 CREATE TABLE tgis_map (
@@ -1494,11 +1582,10 @@ CREATE TABLE tgis_map (
 CREATE INDEX tgis_map_tagente_map_name_idx ON tgis_map(map_name);
 
 CREATE SEQUENCE tgis_map_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tgis_map_inc BEFORE INSERT ON tgis_map REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgis_map_s.nextval INTO :NEW.id_tgis_map FROM dual; END tgis_map_inc;;
 
 -- -----------------------------------------------------
--- Table tgis_map_connection
+-- Table `tgis_map_connection`
 -- -----------------------------------------------------
 --Table to store the map connection information
 CREATE TABLE tgis_map_connection (
@@ -1531,11 +1618,10 @@ CREATE TABLE tgis_map_connection (
 );
 
 CREATE SEQUENCE tgis_map_connection_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tgis_map_connection_inc BEFORE INSERT ON tgis_map_connection REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgis_map_connection_s.nextval INTO :NEW.id_tmap_connection FROM dual; END tgis_map_connection_inc;;
 
 -- -----------------------------------------------------
--- Table tgis_map_has_tgis_map_connection
+-- Table `tgis_map_has_tgis_map_connection`
 -- -----------------------------------------------------
 
 -- This table is commented because table name length is more 30 chars. TODO: Change it's name 
@@ -1559,7 +1645,7 @@ CREATE OR REPLACE TRIGGER tgis_map_connection_inc BEFORE INSERT ON tgis_map_conn
 --CREATE OR REPLACE TRIGGER tgis_map_has_tgis_map_connection_ts BEFORE UPDATE ON tgis_map_has_tgis_map_connection FOR EACH ROW BEGIN select CURRENT_TIMESTAMP into :NEW.modification_time from dual; END;;
 
 -- -----------------------------------------------------
--- Table tgis_map_layer
+-- Table `tgis_map_layer`
 -- -----------------------------------------------------
 --Table containing information about the map layers
 CREATE TABLE tgis_map_layer (
@@ -1578,11 +1664,10 @@ CREATE TABLE tgis_map_layer (
 );
 
 CREATE SEQUENCE tgis_map_layer_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tgis_map_layer_inc BEFORE INSERT ON tgis_map_layer REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tgis_map_layer_s.nextval INTO :NEW.id_tmap_layer FROM dual; END tgis_map_layer_inc;;
 
 -- -----------------------------------------------------
--- Table tgis_map_layer_has_tagente
+-- Table `tgis_map_layer_has_tagente`
 -- -----------------------------------------------------
 --Table to define wich agents are shown in a layer
 CREATE TABLE tgis_map_layer_has_tagente (
@@ -1593,8 +1678,10 @@ CREATE TABLE tgis_map_layer_has_tagente (
 CREATE INDEX tgis_map_layer_has_tagente_idx ON tgis_map_layer_has_tagente(tgis_map_layer_id_tmap_layer);
 CREATE INDEX tgis_map_layer_has_tagent1_idx ON tgis_map_layer_has_tagente(tagente_id_agente);
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- ---------------------------------------------------------------------
--- Table tgroup_stat
+-- Table `tgroup_stat`
 -- ---------------------------------------------------------------------
 --Table to storelobal system stats perroup
 CREATE TABLE tgroup_stat (
@@ -1612,8 +1699,10 @@ CREATE TABLE tgroup_stat (
 	utimestamp NUMBER(10, 0) DEFAULT 0
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
 ------------------------------------------------------------------------
--- Table tnetwork_map
+-- Table `tnetwork_map`
 ------------------------------------------------------------------------
 CREATE TABLE tnetwork_map (
 	id_networkmap NUMBER(10, 0) PRIMARY KEY,
@@ -1650,11 +1739,10 @@ CREATE TABLE tnetwork_map (
 );
 
 CREATE SEQUENCE tnetwork_map_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tnetwork_map_inc BEFORE INSERT ON tnetwork_map REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetwork_map_s.nextval INTO :NEW.id_networkmap FROM dual; END tnetwork_map_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tsnmp_filter
+-- Table `tsnmp_filter`
 -- ---------------------------------------------------------------------
 CREATE TABLE tsnmp_filter (
 	id_snmp_filter NUMBER(10, 0) PRIMARY KEY,
@@ -1663,11 +1751,10 @@ CREATE TABLE tsnmp_filter (
 );
 
 CREATE SEQUENCE tsnmp_filter_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tsnmp_filter_inc BEFORE INSERT ON tsnmp_filter REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tsnmp_filter_s.nextval INTO :NEW.id_snmp_filter FROM dual; END tsnmp_filter_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tagent_custom_fields
+-- Table `tagent_custom_fields`
 -- ---------------------------------------------------------------------
 CREATE TABLE tagent_custom_fields (
 	id_field NUMBER(10, 0) PRIMARY KEY,
@@ -1676,11 +1763,10 @@ CREATE TABLE tagent_custom_fields (
 );
 
 CREATE SEQUENCE tagent_custom_fields_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER tagent_custom_fields_inc BEFORE INSERT ON tagent_custom_fields REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tagent_custom_fields_s.nextval INTO :NEW.id_field FROM dual; END tagent_custom_fields_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tagent_custom_data
+-- Table `tagent_custom_data`
 -- ---------------------------------------------------------------------
 CREATE TABLE tagent_custom_data (
 	id_field NUMBER(10, 0) REFERENCES tagent_custom_fields(id_field) ON DELETE CASCADE,
@@ -1689,6 +1775,8 @@ CREATE TABLE tagent_custom_data (
   PRIMARY KEY (id_field, id_agent)
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- on update trigger
 CREATE OR REPLACE TRIGGER tagent_custom_data_update AFTER UPDATE OF id_field on tagent_custom_fields FOR EACH ROW BEGIN UPDATE tagent_custom_data SET id_field = :NEW.id_field WHERE id_field = :OLD.id_field; END;;
 
@@ -1696,7 +1784,7 @@ CREATE OR REPLACE TRIGGER tagent_custom_data_update AFTER UPDATE OF id_field on
 CREATE OR REPLACE TRIGGER tagent_custom_data_update1 AFTER UPDATE OF id_agente on tagente FOR EACH ROW BEGIN UPDATE tagent_custom_data SET id_agent = :NEW.id_agente WHERE id_agent = :OLD.id_agente; END;;
 
 -- ---------------------------------------------------------------------
--- Table ttag
+-- Table `ttag`
 -- ---------------------------------------------------------------------
 CREATE TABLE ttag ( 
 	id_tag NUMBER(10, 0) PRIMARY KEY, 
@@ -1708,38 +1796,36 @@ CREATE TABLE ttag (
 ); 
 
 CREATE SEQUENCE ttag_s INCREMENT BY 1 START WITH 1;
-
 CREATE OR REPLACE TRIGGER ttag_inc BEFORE INSERT ON ttag REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT ttag_s.nextval INTO :NEW.id_tag FROM dual; END ttag_inc;;
 
 -- ---------------------------------------------------------------------
--- Table ttag_module
+-- Table `ttag_module`
 -- ---------------------------------------------------------------------
-
 CREATE TABLE ttag_module (
 	id_tag NUMBER(10, 0),
 	id_agente_modulo NUMBER(10, 0) DEFAULT 0,
 	id_policy_module NUMBER(10, 0) DEFAULT 0,
 	PRIMARY KEY  (id_tag, id_agente_modulo)
 ); 
-
 CREATE INDEX ttag_module_id_ag_modulo_idx ON ttag_module(id_agente_modulo);
 
--- ---------------------------------------------------------------------
--- Table ttag_policy_module
--- ---------------------------------------------------------------------
+-- This sequence will not work with the 'insert_id' procedure
 
+-- ---------------------------------------------------------------------
+-- Table `ttag_policy_module`
+-- ---------------------------------------------------------------------
 CREATE TABLE ttag_policy_module ( 
 	id_tag NUMBER(10, 0), 
 	id_policy_module NUMBER(10, 0) DEFAULT 0, 
 	PRIMARY KEY  (id_tag, id_policy_module)
-); 
-
+);
 CREATE INDEX ttag_poli_mod_id_pol_mo_idx ON ttag_policy_module(id_policy_module);
 
--- -----------------------------------------------------
--- Table tnetflow_filter
--- -----------------------------------------------------
+-- This sequence will not work with the 'insert_id' procedure
 
+-- -----------------------------------------------------
+-- Table `tnetflow_filter`
+-- -----------------------------------------------------
 CREATE TABLE tnetflow_filter (
 	id_sg NUMBER(10, 0) PRIMARY KEY,
 	id_name VARCHAR2(600),
@@ -1758,9 +1844,8 @@ CREATE SEQUENCE tnetflow_filter_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tnetflow_filter_inc BEFORE INSERT ON tnetflow_filter REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_filter_s.nextval INTO :NEW.id_sg FROM dual; END tnetflow_filter_inc;;
 
 -- -----------------------------------------------------
--- Table tnetflow_report
+-- Table `tnetflow_report`
 -- -----------------------------------------------------
-
 CREATE TABLE tnetflow_report (
 	id_report NUMBER(10, 0) PRIMARY KEY,
 	id_name VARCHAR2(100),
@@ -1773,9 +1858,8 @@ CREATE SEQUENCE tnetflow_report_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tnetflow_report_inc BEFORE INSERT ON tnetflow_report REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_report_s.nextval INTO :NEW.id_report FROM dual; END tnetflow_report_inc;;
 
 -- -----------------------------------------------------
--- Table tnetflow_report_content
+-- Table `tnetflow_report_content`
 -- -----------------------------------------------------
-
 CREATE TABLE tnetflow_report_content (
 	id_rc NUMBER(10, 0) PRIMARY KEY,
 	id_report NUMBER(10, 0) REFERENCES tnetflow_report(id_report) ON DELETE CASCADE,
@@ -1850,7 +1934,7 @@ CREATE SEQUENCE tevent_response_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tevent_response_inc BEFORE INSERT ON tevent_response REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tevent_response_s.nextval INTO :NEW.id FROM dual; END tevent_response_inc;;
 
 -- ---------------------------------------------------------------------
--- Table tcategory
+-- Table `tcategory`
 -- ---------------------------------------------------------------------
 CREATE TABLE tcategory ( 
 	id NUMBER(10, 0) PRIMARY KEY, 
@@ -1868,6 +1952,8 @@ CREATE TABLE tupdate_settings (
 	value VARCHAR2(255) DEFAULT ''
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- ---------------------------------------------------------------------
 -- Table `tupdate_package`
 -- ---------------------------------------------------------------------
@@ -1916,9 +2002,8 @@ CREATE SEQUENCE tupdate_journal_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tupdate_journal_inc BEFORE INSERT ON tupdate_journal REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tupdate_journal_s.nextval INTO :NEW.id FROM dual; END;;
 CREATE OR REPLACE TRIGGER tupdate_journal_update AFTER UPDATE OF id on tupdate FOR EACH ROW BEGIN UPDATE tupdate_journal SET id = :NEW.id WHERE id = :OLD.id; END;;
 
-
 -- ---------------------------------------------------------------------
--- Table talert_snmp_action
+-- Table `talert_snmp_action`
 -- ---------------------------------------------------------------------
 CREATE TABLE talert_snmp_action (
 	id NUMBER(10, 0) PRIMARY KEY,
@@ -1936,11 +2021,15 @@ CREATE TABLE talert_snmp_action (
 	al_field10 CLOB DEFAULT ''
 );
 
+-- This sequence will not work with the 'insert_id' procedure
+
 -- ---------------------------------------------------------------------
--- Table tsessions_php
+-- Table `tsessions_php`
 -- ---------------------------------------------------------------------
 CREATE TABLE tsessions_php (
 	id_session VARCHAR2(52) PRIMARY KEY,
 	last_active NUMBER(20, 0),
 	data CLOB DEFAULT ''
 );
+
+-- This sequence will not work with the 'insert_id' procedure