Improvements on the oracle compatibitily

This commit is contained in:
Alejandro Gallardo Escobar 2015-06-10 17:44:20 +02:00
parent 5751666f45
commit bcfd0237bb
3 changed files with 28 additions and 4 deletions

View File

@ -598,12 +598,23 @@ if (isset( $_GET["fix_module"])) {
$media = reporting_get_agentmodule_data_average ($id_module, 30758400); //Get average over the year
$media *= 1.3;
$error = "";
$result = true;
//If the value of media is 0 or something went wrong, don't delete
if (!empty ($media)) {
$where = array(
'datos' => '>' . $media,
'id_agente_modulo' => $id_module);
db_process_sql_delete('tagente_datos', $where);
$res = db_process_sql_delete('tagente_datos', $where);
if ($res === false) {
$result = false;
$error = modules_get_agentmodule_name($id_module);
}
else if ($res <= 0) {
$result = false;
$error = " - " . __('No data to normalize');
}
}
else {
$result = false;
@ -611,7 +622,7 @@ if (isset( $_GET["fix_module"])) {
}
ui_print_result_message ($result,
__('Deleted data above %d', $media),
__('Deleted data above %f', $media),
__('Error normalizing module %s', $error));
}

View File

@ -204,7 +204,7 @@ if ($multiple_delete) {
if ($result === false)
$error++;
$result = db_process_delete_temp('tagente_datos_inc',
'id_agente_modulo', $id_agent_module_del);
'id_agente_modulo', $id_agent_module_del);
if ($result === false)
$error++;
break;

View File

@ -54,7 +54,20 @@ if ((isset ($_GET["operacion"])) && (!isset ($_POST["update_agent"]))) {
// Copy
foreach ($origen_modulo as $id_agentemodulo) {
echo "<br /><br />".__('Filtering data module')."<b> [".modules_get_agentmodule_name ($id_agentemodulo)."]</b>";
$sql = sprintf ("DELETE FROM tagente_datos WHERE id_agente_modulo = %d AND (datos < '%s' OR datos > '%s')", $id_agentemodulo, $min, $max);
if ($config["dbtype"] == 'oracle') {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < TO_BINARY_DOUBLE('%s')
OR datos > TO_BINARY_DOUBLE('%s'))", $id_agentemodulo, $min, $max);
}
else {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < '%s'
OR datos > '%s')", $id_agentemodulo, $min, $max);
}
db_process_sql ($sql);
}
} //if copy modules or alerts