I've created an oracle stored procedure to fetch data from logminer based on transaction rowid and timestamp. the procedure should try to select from logminer and if it fails as logminer is started on this session it should start it and select the data. The thing is every time the procedure starts the logminer on the same session
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;
how to control this so that the logminer doesnt start everytime?
Please try to replace it with exception ORA-1306 and test few times, since it probably raises other errors internally: