diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 765d5dcbc..d490165a4 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -6,7 +6,9 @@ BEGIN * dejando únicamente los días de retención configurados. */ DECLARE vSchemaName VARCHAR(65); + DECLARE vSchemaNameQuoted VARCHAR(65); DECLARE vTableName VARCHAR(65); + DECLARE vTableNameQuoted VARCHAR(65); DECLARE vRetentionDays INT; DECLARE vStarted DATETIME; DECLARE vDated DATE; @@ -30,13 +32,15 @@ BEGIN IF vRetentionDays THEN SET vStarted = util.VN_NOW(); + SET vSchemaNameQuoted = util.quoteIdentifier(vSchemaName); + SET vTableNameQuoted = util.quoteIdentifier(vTableName); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; - CALL util.exec(CONCAT( - 'DELETE FROM ', util.quoteIdentifier(vSchemaName), - '.', util.quoteIdentifier(vTableName), + EXECUTE IMMEDIATE CONCAT( + 'DELETE FROM ', vSchemaNameQuoted, + '.', vTableNameQuoted, " WHERE creationDate < '", vDated, "'" - )); + ); UPDATE logCleanMultiConfig SET `started` = vStarted,