我创建了一个 oracle 存储过程来根据事务 rowid 和时间戳从 logminer 获取数据。该过程应尝试从 logminer 中进行选择,如果在此会话上启动 logminer 时失败,则应启动它并选择数据。问题是每次程序在同一个会话上启动 logminer
create or replace PROCEDURE TRACK_TRACK (
CDC_TIMESTAMP IN VARCHAR2
,CDC_ROW_ID IN VARCHAR2
,SESSION_NUMBER OUT VARCHAR2
,SERIAL_NUMBER OUT VARCHAR2
,OS_USERNAME OUT VARCHAR2
,MACHINE_NAME OUT VARCHAR2
)
AS
V_LOG_NAME VARCHAR2 (256);
V_CDC_TIME DATE;
V_ROW_ID VARCHAR2 (18);
V_CDC_TIMESTAMP timestamp := to_timestamp (CDC_TIMESTAMP,'YYYYMMDDHH24MISSFF9');
BEGIN
SELECT session#,SERIAL#,'2',MACHINE_NAME,ROW_ID INTO SESSION_NUMBER,SERIAL_NUMBER,OS_USERNAME,MACHINE_NAME,V_ROW_ID FROM V$LOGMNR_CONTENTS
Where ROW_ID=CDC_ROW_ID and TIMESTAMP=V_CDC_TIMESTAMP;
EXCEPTION
WHEN others
THEN
BEGIN
DBMS_LOGMNR.START_LOGMNR (STARTTIME=> SYSDATE-1,ENDTIME=>SYSDATE, OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG
+ DBMS_LOGMNR.CONTINUOUS_MINE);
SELECT session#,SERIAL#,'1',MACHINE_NAME,ROW_ID INTO SESSION_NUMBER,SERIAL_NUMBER,OS_USERNAME,MACHINE_NAME,V_ROW_ID FROM V$LOGMNR_CONTENTS
Where ROW_ID=CDC_ROW_ID and TIMESTAMP=V_CDC_TIMESTAMP;END;
END TRACK_TRACK;
如何控制它以使 logminer 不会每次都启动?