DECLARE
st BOOLEAN := true;
start_scn NUMBER := ?;
BEGIN
FOR l_log_rec IN (
SELECT
MIN(name) name,
first_change#
FROM
(
SELECT
MIN(member) AS name,
first_change#,
281474976710655 AS next_change#
FROM
v$log l
INNER JOIN v$logfile f ON l.group# = f.group#
WHERE l.STATUS = 'CURRENT' OR l.STATUS = 'ACTIVE'
GROUP BY
first_change#
UNION
SELECT
name,
first_change#,
next_change#
FROM
v$archived_log
WHERE
name IS NOT NULL
)
WHERE
first_change# >= start_scn
OR start_scn < next_change#
GROUP BY
first_change#
ORDER BY
first_change#
) LOOP IF st THEN
SYS.DBMS_LOGMNR.add_logfile(l_log_rec.name, SYS.DBMS_LOGMNR.new);
st := false;
ELSE
SYS.DBMS_LOGMNR.add_logfile(l_log_rec.name);
END IF;
END LOOP;
SYS.DBMS_LOGMNR.start_logmnr( options => SYS.DBMS_LOGMNR.skip_corruption + SYS.DBMS_LOGMNR.no_sql_delimiter + SYS.DBMS_LOGMNR.no_rowid_in_stmt
+ SYS.DBMS_LOGMNR.dict_from_online_catalog + SYS.DBMS_LOGMNR.string_literals_in_stmt );
END;