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
What is trigger point?
What are sql data types?
explain advantages of myisam over innodb? : Sql dba
Write the alter statement to enable all the triggers on the t.students table.
What is sql not null constraint?
Does sql use python?
how to extract a unit value from a date and time? : Sql dba
What is an escape character in sql?
What is the starting oracle error number? What is meant by forward declaration in functions?
Do stored procedures prevent sql injection?
What are aggregate functions in sql?
What are the types of optimization?
Should I use mbr or gpt?
How do you delete data from a table?
What is foreign key sql?