diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index cba718f54e..80d2fbb401 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2011-12-01 Juan Manuel Ramon + + * lib/PandoraFMS/DB.pm + lib/PandoraFMS/Core.pm: Added new function db_concat and added + compatibility with postgreSQL and Oracle in function + pandora_get_module_tags. + 2011-11-29 Juan Manuel Ramon * util/pandora_manage.pl: Added some checks that I forget in my diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index fa068fd5dc..1be4827951 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2557,8 +2557,7 @@ Get a list of module tags in the format: |tag|tag| ... |tag| sub pandora_get_module_tags ($$$) { my ($pa_config, $dbh, $id_agentmodule) = @_; - #TODO: Fix for Oracle and PostgreSQL - my @tags = get_db_rows ($dbh, 'SELECT concat(ttag.name, " ", ttag.url) name_url FROM ttag, ttag_module + my @tags = get_db_rows ($dbh, 'SELECT ' . db_concat('ttag.name', 'ttag.url') . ' name_url FROM ttag, ttag_module WHERE ttag.id_tag = ttag_module.id_tag AND ttag_module.id_agente_modulo = ?', $id_agentmodule); diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 69e70b749f..7b927918bf 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -30,6 +30,7 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( add_address add_new_address_agent + db_concat db_connect db_disconnect db_do @@ -628,6 +629,17 @@ sub get_alert_template_name ($$) { return get_db_value ($dbh, "SELECT name FROM talert_templates, talert_template_modules WHERE talert_templates.id = talert_template_modules.id_alert_template AND talert_template_modules.id = ?", $alert_id); } +########################################################################## +## Concat two strings +########################################################################## +sub db_concat ($$) { + my ($element1, $element2) = @_; + + return " concat(" . $element1 . ", ' '," . $element2 . ") " if ($RDBMS eq 'mysql'); + return " " . $element1 . " || ' ' || " . $element2 . " " if ($RDBMS eq 'oracle' or $RDBMS eq 'postgresql'); + +} + # End of function declaration # End of defined Code