How to maintain the history of code changes of pl/sql?

Answer Posted / guru

--

CREATE TABLE SOURCE_HIST -- Create
history table
AS SELECT SYSDATE CHANGE_DATE, USER_SOURCE.*
FROM USER_SOURCE WHERE 1=2;

CREATE OR REPLACE TRIGGER change_hist --
Store code in hist table
AFTER CREATE ON SCOTT.SCHEMA --
Change SCOTT to your schema name
DECLARE
BEGIN
if DICTIONARY_OBJ_TYPE in ('PROCEDURE', 'FUNCTION',
'PACKAGE', 'PACKAGE BODY', 'TYPE')
then
-- Store old code in SOURCE_HIST table
INSERT INTO SOURCE_HIST
SELECT sysdate, user_source.* FROM USER_SOURCE
WHERE TYPE = DICTIONARY_OBJ_TYPE
AND NAME = DICTIONARY_OBJ_NAME;
end if;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, SQLERRM);
END;
/
show errors
--

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I delete duplicate rows?

733


What is the difference between local and global temporary table?

748


Does a join table need a primary key?

706


Can we join two tables without common column?

695


What is difference between db2 and sql?

717






Do we need to create index on primary key?

637


How do you use join?

700


Explain aggregate functions are available there in sql?

748


What are different joins used in sql?

721


Can we edit a view in sql?

711


Are pl sql variables case sensitive?

767


How do I use google cloud in sql?

724


How do you use a while loop in pl sql?

714


What is the use of function in sql?

725


what is log shipping? : Sql dba

819