Home » SQL & PL/SQL » SQL & PL/SQL » Can I revert back package changes to prev version? (Oracle 10g)
Can I revert back package changes to prev version? [message #549236] Thu, 29 March 2012 01:25 Go to next message
hari_bk
Messages: 110
Registered: March 2006
Senior Member
Hi

I overwritten the package and want to get the previous version.

Is there a way I can get it using FLASHBACK or any other feature?

My user_recyclebin is showing only tables.


SELECT object_name, original_name, TYPE
  FROM user_recyclebin;



Thanks
Re: Can I revert back package changes to prev version? [message #549248 is a reply to message #549236] Thu, 29 March 2012 02:29 Go to previous messageGo to next message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Maybe you can take it from your "source version control" tool?

You can try to query sys.source$ using "AS OF TIMESTAMP" clause.

Regards
Michel
Re: Can I revert back package changes to prev version? [message #549669 is a reply to message #549236] Tue, 03 April 2012 00:34 Go to previous messageGo to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi,

You may also get it from SYS.AUD$. I don't know much detail about this but it contain history of compilations when auditing is on.

Regards
Manoj
Re: Can I revert back package changes to prev version? [message #549679 is a reply to message #549669] Tue, 03 April 2012 00:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
You may also get it from SYS.AUD$.


No, you can't.

Regards
Michel
Re: Can I revert back package changes to prev version? [message #549682 is a reply to message #549679] Tue, 03 April 2012 01:02 Go to previous messageGo to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi Michel,

We can get I'm 100% sure. I don't know what we need to enable for this. If you check definition of this view there is a field for SQL Text.

We used this view in our previous project.

Thanks & Regards
Manoj
Re: Can I revert back package changes to prev version? [message #549687 is a reply to message #549682] Tue, 03 April 2012 01:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
If you check definition of this view there is a field for SQL Text.


And how this gives the "previous" version?

Quote:
We used this view in our previous project


As a "source version control"? Gee, I just don't want to be one of your client, tell me for whom you worked.

Regards
Michel
Re: Can I revert back package changes to prev version? [message #549691 is a reply to message #549687] Tue, 03 April 2012 01:43 Go to previous messageGo to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi Michel

Please open below link here is written something for CREATE/DROP Procedure, Function, Package etc.

http://psoug.org/reference/auditing.html

Michel Cadot wrote on Tue, 03 April 2012 11:43

tell me for whom you worked.

This is confidential matter. I should not discuss this here.

Thanks & Regards
Manoj
Re: Can I revert back package changes to prev version? [message #549694 is a reply to message #549691] Tue, 03 April 2012 01:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Once again, a CREATE OR REPLACE PROCEDURE will NOT give you what was the previous code.
Anyway, it is irrelevant to use audit as a source version control.

Regards
Michel
Re: Can I revert back package changes to prev version? [message #549926 is a reply to message #549236] Wed, 04 April 2012 13:25 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
SQL> show user
USER is "SYS"
SQL> grant flashback on user_source to hr
  2  /

Grant succeeded.

SQL> conn HR/HR
Connected.
SQL> create or replace procedure prc001
  2  as
  3  begin
  4  dbms_output.put_line('>>>> Print A<<<<<');
  5  end;
  6  /

Procedure created.

SQL> select text from user_source where name = 'PRC001';

TEXT                                                                            
--------------------------------------------------------------------------------
procedure prc001                                                                
as                                                                              
begin                                                                           
dbms_output.put_line('>>>> Print A<<<<<');                                      
end;                                                                            

SQL> ED
Wrote file afiedt.buf

  1* select text from user_source where name = 'PRC001'
SQL> 
SQL> create or replace procedure prc001
  2  as
  3  begin
  4  dbms_output.put_line('>>>> Print B<<<<<');
  5  end;
  6  /

Procedure created.

SQL> select text from user_source where name = 'PRC001';

TEXT                                                                            
--------------------------------------------------------------------------------
procedure prc001                                                                
as                                                                              
begin                                                                           
dbms_output.put_line('>>>> Print B<<<<<');                                      
end;                                                                            


SQL> select text from user_source as of scn timestamp_to_scn(systimestamp - 10/1440)
  2      where name = 'PRC001';

no rows selected

SQL> select text from user_source as of scn timestamp_to_scn(systimestamp - 5/1440)
  2      where name = 'PRC001';

TEXT                                                                            
--------------------------------------------------------------------------------
procedure prc001                                                                
as                                                                              
begin                                                                           
dbms_output.put_line('>>>> Print B<<<<<');                                      
end;                                                                            

SQL> select text from user_source as of scn timestamp_to_scn(systimestamp - 7/1440)
  2      where name = 'PRC001';

TEXT                                                                            
--------------------------------------------------------------------------------
procedure prc001                                                                
as                                                                              
begin                                                                           
dbms_output.put_line('>>>> Print A<<<<<');                                      
end;  


Source: http://myracle.wordpress.com/2007/09/05/plsql-code-versioning-possible-in-oracle-10g-with-flashack/

Regards
Ved
Re: Can I revert back package changes to prev version? [message #549927 is a reply to message #549926] Wed, 04 April 2012 13:35 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Posted example is the equivalent of using hammer to divide a board into two pieces.
better tools exist to complete specific tasks
Re: Can I revert back package changes to prev version? [message #549932 is a reply to message #549926] Wed, 04 April 2012 13:55 Go to previous message
Michel Cadot
Messages: 68757
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
1/ About audit

And what if the code is changed once per year or even month?
Do you have one month of audit inline?

Once again it is the wrong way, it is NOT a practical way and, anyway, it will not answer the question as if OP has no source version control tool then it has no audit on the database.

2/ About flashback

Note that flashback on source$ is the FIRST thing I suggested and it is of course limited to undo segment data, I even wonder if it is not limited by the small SYSTEM rollback segment. Anyway, it is even more limited than audit.

Regards
Michel

[Updated on: Wed, 04 April 2012 13:59]

Report message to a moderator

Previous Topic: Ora-04062 Timestamp Changed
Next Topic: Please tell me wher query is wrong
Goto Forum:
  


Current Time: Sat Apr 26 00:03:27 CDT 2025