SYSDATE - pl / sql函数错误1

时间:2009-04-23 15:56:27

标签: oracle plsql ora-06512

我有一个问题:

当我在下面发出这个功能时,ti会给我以下错误:

select 'EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =>'''||name||'''||,OPTIONS=>DBMS_LOGMNR.NEW);'
 from v\$archived_log 
where name is not null;

select 'EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =>'''||name||'''||,OPTIONS=>DBMS_LOGMNR.ADDFILE);' 
 from v\$archived_log 
where name is not null;


EXECUTE DBMS_LOGMNR.START_LOGMNR( STARTTIME => SYSDATE - 1, ENDTIME => SYSDATE,
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE +
DBMS_LOGMNR.COMMITTED_DATA_ONLY + DBMS_LOGMNR.PRINT_PRETTY_SQL);

Error:

*
ERROR at line 1:
ORA-01291: missing logfile
ORA-06512: at "SYS.DBMS_LOGMNR", line 58
ORA-06512: at line 1

但我之前已经添加了所有存档日志,而且我的sysdate就在今天。

请帮助解决这个问题。

感谢。

Reagrds

亚青

2 个答案:

答案 0 :(得分:1)

您需要从前两个查询中获取值并实际执行它们,但无论如何您似乎都有语法错误。

BEGIN
  FOR CUR_NEW IN ( 
    select 'CALL DBMS_LOGMNR.ADD_LOGFILE(' ||
           'LOGFILENAME =>'''||name||''','||
           'OPTIONS=>DBMS_LOGMNR.NEW);' as COMM
    from v$archived_log 
    where name is not null
  ) LOOP
    EXECUTE IMMEDIATE CUR_NEW.COMM;
  END LOOP;

  FOR CUR_ADD IN ( 
    select 'CALL DBMS_LOGMNR.ADD_LOGFILE(' ||
           'LOGFILENAME =>'''||name||''','||
           'OPTIONS=>DBMS_LOGMNR.ADDFILE);' as COMM
    from v$archived_log 
    where name is not null
  ) LOOP
    EXECUTE IMMEDIATE CUR_ADD.COMM;
  END LOOP;

  EXECUTE IMMEDIATE 'CALL DBMS_LOGMNR.START_LOGMNR( ' ||
    'STARTTIME => SYSDATE - 1, ' ||
    'ENDTIME => SYSDATE, ' ||
    'OPTIONS => ' ||
      '  DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG '||
      '+ DBMS_LOGMNR.CONTINUOUS_MINE '||
      '+ DBMS_LOGMNR.COMMITTED_DATA_ONLY '||
      '+ DBMS_LOGMNR.PRINT_PRETTY_SQL)';
END;

答案 1 :(得分:0)

好像你运行了选择但没有执行句子。