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
How many developers work on postgresql?
How subquery works in sql?
What does the base_object_type column shows in the user.triggers data dictionary view?
What is nvarchar in sql?
What is sql and explain its components?
Why use triggers in sql?
What is union?
What is union, minus and interact commands?
What is rename in sql?
how to concatenate two character strings? : Sql dba
What is difference between joins and union?
Which operator is used in query for pattern matching?
What is sql performance tuning?
Explain the difference between cursor declared in procedures and cursors declared in the package specification?
What does desc stand for?