我有一个可以正常工作的程序,直到我错误地将其替换为其他代码。
因此,我的过程从CREATE OR REPLACE PROCEDURE xxx.yyy
开始,然后我错误地替换了一些简单的代码并保存了它。
由于我在程序中进行了替换,因此它被替换了,但是现在它不再以我想要的方式工作。如何获得该过程中的旧代码(在替换之前)?
答案 0 :(得分:2)
以xxx
模式连接时,请尝试使用:
select s.text
from user_source
as of timestamp systimestamp - interval '1' day s
where s.name = 'YYY';
获取过程源。它为您提供前一天的数据。如果您的'1' day
数据库参数已设置得足够大,则可以根据需要将'10' hour
转换为'150' minute
,db_flashback_retention_target
等。 em>
答案 1 :(得分:0)
在搜索期间是否有存档日志。您可以使用实用程序LogMiner。 例如:
CREATE OR REPLACE PACKAGE BODY acs_ss2.rest_of_day is
/*------------------------------------------------------------------*/
procedure starting(p_date date) is
rec_newrest r_rest%rowtype;
rec_oldrest r_rest%rowtype;
rec_rest r_rest%rowtype;
v_station integer := 8902;
v_dt1 date;
v_dt2 date;
begin
SQL CODE...
在事件发生时确定所需的日志文件。
select name, first_time, next_time
from v$archived_log
where first_time >sysdate -3/24
/oracle/app/oracle/product/11.2/redolog/edcu/1_47429_769799469.dbf 22-ноя-2018 10:56:12 22-ноя-2018 12:13:48
/oracle/app/oracle/product/11.2/redolog/edcu/1_47430_769799469.dbf 22-ноя-2018 12:13:48 22-ноя-2018 13:17:06
/oracle/app/oracle/product/11.2/redolog/edcu/1_47431_769799469.dbf 22-ноя-2018 13:17:06 22-ноя-2018 13:39:38
运行logminer实用程序。
EXECUTE DBMS_LOGMNR.add_logfile(LOGFILENAME => '/oracle/app/oracle/product/11.2/redolog/edcu/1_47429_769799469.dbf', OPTIONS => DBMS_LOGMNR.NEW);
EXECUTE DBMS_LOGMNR.add_logfile(LOGFILENAME => '/oracle/app/oracle/product/11.2/redolog/edcu/1_47430_769799469.dbf', OPTIONS => DBMS_LOGMNR.addfile);
EXECUTE DBMS_LOGMNR.add_logfile(LOGFILENAME => '/oracle/app/oracle/product/11.2/redolog/edcu/1_47431_769799469.dbf', OPTIONS => DBMS_LOGMNR.addfile);
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
运行SQL以恢复我们的CODE,请参见sql_undo列。
SELECT
to_char(timestamp,'DD-MM-YYYY HH24:MI:SS'),
operation,
sql_redo,
sql_undo
FROM v$logmnr_contents
where
seg_owner='SYS' and
seg_name='SOURCE$'
==>
TO_CHAR(TIMESTAMP,'DD-MM-YYYYHH24:MI:SS') OPERATION SQL_REDO SQL_UNDO
----------------------------------------------- -------------------------------------- ---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
22-11-2018 13:39:14 DELETE delete from "SYS"."SOURCE$" where "OBJ#" = '197353' and "LINE" = '1' and "SOURCE" = 'package body re insert into "SYS"."SOURCE$"("OBJ#","LINE","SOURCE") values ('197353','1','package body rest_of_day i
22-11-2018 13:39:14 DELETE delete from "SYS"."SOURCE$" where "OBJ#" = '197353' and "LINE" = '2' and "SOURCE" = '
' and ROWID = insert into "SYS"."SOURCE$"("OBJ#","LINE","SOURCE") values ('197353','2','
');
22-11-2018 13:39:14 DELETE delete from "SYS"."SOURCE$" where "OBJ#" = '197353' and "LINE" = '3' and "SOURCE" = '/*------------- insert into "SYS"."SOURCE$"("OBJ#","LINE","SOURCE") values ('197353','3','/*------------------------
22-11-2018 13:39:14 DELETE delete from "SYS"."SOURCE$" where "OBJ#" = '197353' and "LINE" = '4' and "SOURCE" = 'procedure start insert into "SYS"."SOURCE$"("OBJ#","LINE","SOURCE") values ('197353','4','procedure starting(p_date
22-11-2018 13:39:14 DELETE delete from "SYS"."SOURCE$" where "OBJ#" = '197353' and "LINE" = '5' and "SOURCE" = ' rec_newrest r insert into "SYS"."SOURCE$"("OBJ#","LINE","SOURCE") values ('197353','5',' rec_newrest r_rest%rowty