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




Answers were Sorted based on User's Feedback



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

Answer / arup ratan banerjee

U CAN REFER ALL_SOURCE TABLE...
SELECT * FROM ALL_SOURCE WHERE OWNER='IHIS11'
AND TYPE = 'PROCEDURE';


U will get procedure body from this table

Is This Answer Correct ?    4 Yes 0 No

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

Answer / 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 1 No

Post New Answer




More SQL PLSQL Interview Questions

Does a user_objects view have an entry for a trigger?

0 Answers  


What is difference between select statement and cursor

3 Answers   JDA,


What is oracle ? why we should go for oracle database instead of diffrent databases available in the industry.

5 Answers   Polaris,


how can i read files from a pl/sq l program

3 Answers  


have table with two columns with datatypes as number and varchar and the values in A column like 1,2,3 AND B column values like a,b,c. now need to display data in a single column as 1,a,2,b,3,c.

8 Answers   IBM, Zensar,






What is Histogram?

0 Answers   NIIT,


Hi Guys, I have a situation where I need to access the column values from rowtype variable. However, the column names are dynamic. below is sample code: declare Cursor c1 is select * from emp; Cursor c2 is select column_name from xyztable; v_c2 c2%rowtype; v_str varchar2 v_value varchar2(200); begin for rec in c1 loop open c2;---this cursor has column names like EMPLOYEE_ID, FIRST_NAME, LAST_NAME etc. loop fetch c2 into v_c2; exit when c2%notfound; /* now lets say i want to access value of LAST_NAME from cursor c1, so I am writing below code, however it does not work as expected */ v_str:= 'rec.'|| v_c2.column_name; -- this will give me string like "rec.EMPLOYEE_ID" v_value:=v_str; end loop; end loop; end; / Plz help ASAP.Thanks.

2 Answers  


declare l1 number := null; l2 number :=null; begin if l1=l2 then message('equal'); else if l1<>l2 then message('not equal'); else message('else'); end if; end if; end; What will be the output ?

7 Answers   Oracle,


What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?

1 Answers  


How to generate a salary slip like jan 1000 1000 feb 1000 2000 ... dec 1000 12000

0 Answers   BT,


What are the uses of sysdate and user keywords?

0 Answers  


HOW TO TUNE ORACLE SQL QUERIES GIVE ME STEP BY SREP

1 Answers   TCS,






Categories