Purge logs by date

This commit is contained in:
Jan Kvetina 2021-12-27 19:59:51 +01:00
parent b13a5cd615
commit 002ce835da
2 changed files with 31 additions and 0 deletions

View File

@ -900,6 +900,15 @@ CREATE OR REPLACE PACKAGE app AS
--
-- Purge specific day
--
PROCEDURE purge_logs (
in_date DATE
);
--
-- Returns procedure name which called this function with possible offset
--

View File

@ -2070,6 +2070,28 @@ CREATE OR REPLACE PACKAGE BODY app AS
PROCEDURE purge_logs (
in_date DATE
) AS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
DELETE FROM logs l
WHERE l.created_at >= in_date
AND l.created_at < in_date + 1;
--
DELETE FROM sessions s
WHERE s.created_at >= in_date
AND s.created_at < in_date + 1;
--
COMMIT;
EXCEPTION
WHEN OTHERS THEN
COMMIT;
app.raise_error();
END;
FUNCTION get_caller_name (
in_offset PLS_INTEGER := NULL
)