DBA_SOURCE / DBA_DEPENDENCIES
Hi
I am trying to find dependencies for package using dba_dependencies.
It gives me all the dependencies (tables and objects) used inside the package.
Is there a way to find attribute dependency and procedure name in a package
table_name / column_name / package.procedure line text /
Thanks
look at that:
http://www.webservertalk.com/archive151-2005-6-1092394.html
Oracle has a utlity that does something similar, that can be installed
by running utldtree.sql. It includes a deptree_fill procedure. With a
little modification of the deptree_fill procedure, you can make your
own reverse_deptree_fill procedure, that should do about what you want.
You may want to add some additional modifications or filter the result
set when you query. Please see the demonstration below.
scott@ORA92> -- function and views for demonstration:
scott@ORA92> CREATE OR REPLACE FUNCTION funca
2 RETURN NUMBER
3 AS
4 BEGIN
5 RETURN 1;
6 END funca;
7 /
Function created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> CREATE OR REPLACE VIEW viewc AS SELECT funca () some_col
FROM DUAL
2 /
View created.
scott@ORA92> CREATE OR REPLACE VIEW viewb AS SELECT * FROM viewc
2 /
View created.
scott@ORA92> CREATE OR REPLACE VIEW viewa AS SELECT * FROM viewb
2 /
View created.
scott@ORA92> -- install Oracle utility
scott@ORA92> -- (substutiting your own Oracle home directory path):
scott@ORA92> START d:\oracle\ora92\rdbms\admin\utldtree.sql
scott@ORA92> -- output of installation ommitted to save space
scott@ORA92> -- create reverse_deptree_fill procedure
scott@ORA92> -- as modification of deptree_fill procedure:
scott@ORA92> create or replace procedure reverse_deptree_fill
2 (type char,
3 schema char,
4 name char)
5 is
6 obj_id number;
7 begin
8 delete from deptree_temptab;
9 commit;
10 select object_id into obj_id from all_objects
11 where owner = upper(reverse_deptree_fill.schema)
12 and object_name = upper(reverse_deptree_fill.name)
13 and object_type = upper(reverse_deptree_fill.type);
14 insert into deptree_temptab
15 values(obj_id, 0, 0, 0);
16 insert into deptree_temptab
17 select referenced_object_id, object_id,
18 level, deptree_seq.nextval
19 from public_dependency
20 connect by prior referenced_object_id = object_id
21 start with object_id = reverse_deptree_fill.obj_id;
22 exception
23 when no_data_found then
24 raise_application_error
25 (-20000,
26 type || ' ' || schema || '.' || name || ' was not found.');
27 end reverse_deptree_fill;
28 /
Procedure created.
scott@ORA92> show errors
No errors.
scott@ORA92> -- execute the reverse_deptree_fill procedure
scott@ORA92> -- to populate the deptree_temptab table:
scott@ORA92> EXECUTE reverse_deptree_fill ('VIEW', 'SCOTT', 'VIEWA')
PL/SQL procedure successfully completed.
scott@ORA92> -- select from the deptree_temptab table:
scott@ORA92> SELECT * FROM deptree_temptab
2 /
OBJECT_ID REFERENCED_OBJECT_ID NEST_LEVEL SEQ#
89801 0 0 0
89800 89801 1 89
89799 89800 2 90
64763 89799 3 91
223 89799 3 92
222 89799 3 93
89750 89799 3 94
647 89750 4 95
89750 89800 2 96
647 89750 3 97
89750 89801 1 98
647 89750 2 99
12 rows selected.
scott@ORA92> -- select from the deptree view:
scott@ORA92> SELECT * FROM deptree
2 /
NESTED_LEVEL TYPE SCHEMA NAME SEQ#
3 TABLE SYS DUAL 93
3 SYNONYM PUBLIC DUAL 92
4 PACKAGE SYS STANDARD 95
2 PACKAGE SYS STANDARD 99
3 PACKAGE SYS STANDARD 97
3 91
3 FUNCTION SCOTT FUNCA 94
1 FUNCTION SCOTT FUNCA 98
2 FUNCTION SCOTT FUNCA 96
2 VIEW SCOTT VIEWC 90
1 VIEW SCOTT VIEWB 89
0 VIEW SCOTT VIEWA 0
12 rows selected.
scott@ORA92> -- select from the ideptree view:
scott@ORA92> SELECT * FROM ideptree
2 /
DEPENDENCIES
VIEW SCOTT.VIEWA
VIEW SCOTT.VIEWB
VIEW SCOTT.VIEWC
<no permission>
SYNONYM PUBLIC.DUAL
TABLE SYS.DUAL
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
FUNCTION SCOTT.FUNCA
PACKAGE SYS.STANDARD
12 rows selected.
scott@ORA92>
Similar Messages
-
Trigger does not exists in DBA_SOURCE
hi all,
what may be the reason as some of the triggers are not found in DBA_SOURCE,
SQL>select count(*) from(
2 select trigger_name from dba_triggers
3 minus
4 select name from dba_source where type='TRIGGER'
5 )
6 ;
COUNT(*)
168
I also confirmed from DBA_TRIGGERS for source existance
I am using 10.2.0.3 databaseYou can see all triggers via dba_triggers. When triggers were first introduced back in version 7 triggers were not compiled, but triggers are now compiled. I have found user created triggers not in dba_source on 9.2. When I manually compile the trigger it then shows in dba_source as do triggers I have re-created recently.
You might try comparing dba_triggers to dba_source and then manually compiling all missing triggers then checking again.
I have yet to get around to doing this so I would find your results interesting.
HTH -- Mark D Powell -- -
DBA_DEPENDENCIES: 11gR2 fine-grained dependency tracking -- which columns??
DBA_DEPENDENCIES is great, but I need to know the dependent columns. Given that 11g supports fine-grained dependency tracking... for example:
create view emp_view as
select emp_no, emp_name
from employees
where emp_no in (select emp_no from employees where hire_date > sysdate-2000)
EMP_VIEW only exposes EMP_NO and EMP_NAME.
If I drop the column EMPLOYEES.HIRE_DATE, Oracle will not invalidate objects that reference just EMP_NO and EMP_NAME, but in this case Oracle immediately invalidates EMP_VIEW because the view definition contains HIRE_DATE.
Where does Oracle store this column dependency? Only at the table/view/function level in DBA_DEPENDENCIES. Maybe in an X$ table somewhere?
Or does Oracle do an "on the fly" check for the dropped column in all dependent objects (seems messy).
Before I change any table or view, I want to know what else I may have to change without finding out the hard way. I can easily look at the view's column list, but if I have to go into the view text, or the function text... messy! Must be a better way.
Thanks.
BBExactly what I needed. Not sure why I didn't find this with the ten different Google searches I did...
-
Function to be inserted into dba_source
Hello Gurus,
I have to update an existing function which is in dba_source how do I go about doing it.
Please let me know
ShivaIt works for me...
SQL> create or replace function abc return number as
2 begin
3 return 1;
4 end;
5 /
Function created.
SQL> select text from dba_source where name='ABC';
TEXT
function abc return number as
begin
return 1;
end;
SQL> create or replace function abc return number as
2 begin
3 return 2;
4 end;
5 /
Function created.
SQL> select text from dba_source where name='ABC';
TEXT
function abc return number as
begin
return 2;
end;
SQL> -
Can we get the complete code from dba_source? Say,we have a 50000 lines of code for an object so by querying the text column will I be able to get all of them?
Why I am being a bit skeptic is because the text column is a VARCHAR2(4000) so will it hold a content having more than that material?Well, in fact I did, but when i tried to display it using DBMS_OUTPUT, it's all messy
declare
v_query varchar2(300);
v_ddl_clob clob;
v_offset number;
v_clobsize number;
v_exit_flag boolean;
begin
for rec in (select object_type,object_name,owner from dba_objects
where object_type in ('PROCEDURE','FUNCTION','PACKAGE') and owner in ('MY_SCHEMA1','MY_SCHEMA2')
and object_name in ('MY_PCK1','MY_PCK2'))
loop
begin
dbms_output.put_line ('Schema :- '||rec.owner||','||rec.object_type||' - '||rec.object_name);
v_query := 'select dbms_metadata.get_ddl('''||rec.object_type||''','''||rec.object_name||''','''||rec.owner||''') ddl from dual';
dbms_output.put_line ('Query : '||v_query);
execute immediate v_query into v_ddl_clob;
v_offset := 1;
v_clobsize := dbms_lob.getlength(v_ddl_clob);
dbms_output.put_line ('Size : '||v_clobsize);
v_exit_flag := TRUE;
while v_exit_flag
loop
dbms_output.put_line('showing from character --'||to_char(v_offset));
v_ddl := null;
v_ddl := dbms_lob.substr(v_ddl_clob,32700,v_offset);
dbms_output.put_line(v_ddl);
if ((v_clobsize > 32700) AND ((v_clobsize-v_offset) > 32700)) then
dbms_output.put_line ('here2');
v_offset := v_offset + least(32700, (v_clobsize-v_offset));
dbms_output.put_line('next offset --'||to_char(v_offset));
dbms_output.put_line('total chars left --'||to_char(v_clobsize-v_offset));
else
dbms_output.put_line ('here1');
v_exit_flag := FALSE;
end if;
dbms_output.put_line ('here2');
end loop;
dbms_output.put_line ('end of file...');
exception
when others then
dbms_output.put_line ('Error1 :-'||sqlerrm);
end;
end loop;
exception
when others then
dbms_output.put_line ('Error2 :-'||sqlerrm);
end; -
select * from dba_source
where owner = 'SYS'
and name like 'DBMS%'
and type = 'PACKAGE'
;am i right to use the code above to list the packages that is available to be use on my XE?
It listed dbms_redef
NAME TYPE
DBMS_LOGREP_DEF_PROC_UTL PACKAGE
DBMS_METADATA_UTIL PACKAGE
DBMS_NETWORK_ACL_ADMIN PACKAGE
DBMS_NETWORK_ACL_UTILITY PACKAGE
DBMS_PLUGTSP PACKAGE
DBMS_PREPROCESSOR PACKAGE
DBMS_PROPAGATION_ADM PACKAGE
DBMS_PRVTAQIM PACKAGE
DBMS_PRVTAQIS PACKAGE
DBMS_RECTIFIER_FRIENDS PACKAGE
DBMS_REDEFINITION PACKAGE which i am sure it did not supported at all .Are you asking "Is DBMS_REDEFINITION available on Express Edition ?"
If this is your question then :
Yes, it is.
See example : http://ora-exp.blogspot.in/2006/11/online-ddl-modifications-in-oracle_14.html
else
Please post your question again.
end if;
Regards
Girish Sharma -
About DBA_DEPENDENCIES and REFERENCED_LINK_NAME
Hi, i have a question about, the info of DBA_DEPENDENCIES, i found the next two rows on the same database, and i don't understand why they are about the same synonym, that uses a database link, but here it appears two times, once with the db_link that it is related to, and other without the db_link.
OWNER NAME TYPE REF_OWNER REF_NAME REF_TYPE REF_LINK_NAME DEPENDENCY_TYPE
SCHEMAX PROCX PROCEDURE PUBLIC SYNONYMX SYNONYM DB_LINK_X HARD
SCHEMAX PROCX PROCEDURE PUBLIC SYNONYMX SYNONYM NULL HARDSomebody knows what is the reason of this?
Thank you.
Edited by: user11173393 on 10/12/2010 02:26 PM
Edited by: user11173393 on 10/12/2010 02:27 PMhttp://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:3225568207176
+"+
+We are missing something in this discussion. Just wanted to Add to it and would also like to know.+
+How can we find out depencenies on the Objects of a remote database. Let's assume I have created a+
+view and i am referring to a table of Remote database using DB_LINK.+
+How can i find out these kind of dependencies. I tried to user DBA_DEPENDENCIES.+
+DBA_DEPENDENCIES describes all dependencies in the database between procedures, packages,+
+functions, package bodies, and triggers, including dependencies on views created without any+
+database links.+
+Followup December 23, 2009 - 7am Central time zone:+
+Your object is dependent on the database link - and that is all.+
+I like to use views, as they import the metadata of the remote table and it is pretty clear what the view refers to to (single table view). It makes the compilation of the procedure a bit speedier as well since the procedure is dependent on the view, not on the database link behind the view - we don't need to even open the link to compile the procedure.+
+"+
Hope This Helps.
Ogan -
Grants on dba_dependencies table
Version:oracle 10g
tool: sqldeveloper
Hi Experts,
I have created a procedure in scott schema by using the cursor from the table DBA_DEPENDENCIES and DBA_OBJECTS,
but its giving the error table does not exists,
I have asked our dba to provide the read access to this table ,
and after providing the read access I could be able to select from the editor but again could not use in the procedure.
Again its giving table or view does not exists.
Please help me to come out of this.
Note: I don't want to use all_dependencies since its not giving all data which I require.
Thanks in advance.....What was the exact grant that the DBA issued? If you're still getting an ORA-00942 error, that's a pretty convincing argument that the DBA did not, in fact, grant the owner of the procedure direct SELECT access on DBA_DEPENDENCIES.
Was the DBA attempting to give the grant on just that object? Or did he grant the owner the SELECT ANY DICTIONARY privilege?
Can you cut and paste from a SQL*Plus session that shows that
1) the direct grant to the owner of the procedure is in place
and
2) the procedure that selects from DBA_DEPENDENCIES does not compile
Justin -
hi,
i was reading oracle doc about dba_dependencies and found it contradicting. Below mention that but the column of the views allows one to do
- REFERENCED_LINK_NAME VARCHAR2(128) Name of the link to the parent object (if remote)
- SCHEMAID NUMBER ID of the current schema
ALL_DEPENDENCIES describes dependencies between procedures, packages, functions, package bodies, and triggers accessible to the current user, including dependencies on views created without any database links. This view does not display the SCHEMAID column.
http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_1041.htmHi;
Please see below link which could be helpful for your issue:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3225568207176
Queryh on DBA_DEPENDENCIES
Regard
Helios -
How to find object dependencies using the DBA_DEPENDENCIES
Hi,
Could some one please help me in finding out the object dependencies among objects?
I was trying to find out the all levels of dependencies for a given object in a given schema, but this following query is not working for packages type.
I want to find out all LEVELS of object involved in the creation of a package.
Example:
SELECT DISTINCT owner,name,referenced_owner,referenced_name,referenced_type, LEVEL Le1
FROM dba_dependencies
where owner =user
START WITH NAME = 'object name'
CONNECT BY NOCYCLE PRIOR referenced_name = NAME
--AND PRIOR REFERENCED_OWNER = OWNER
--AND REFERENCED_TYPE = 'PACKAGE'
ORDER SIBLINGS BY name
Please help.Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
WITH v AS (
SELECT line
,col
,name
,object_type
,object_name
,type
,usage
,usage_id
,usage_context_id
FROM user_identifiers
WHERE object_name = 'XML_SPREADSHEET'
AND object_type = 'PACKAGE'
SELECT LEVEL,LPAD(' ', 2*(LEVEL-1)) ||NAME
,object_type
,type
,usage
,line
FROM v
START WITH name = 'T_REC_CAPTION'
CONNECT BY PRIOR usage_id = usage_context_id
ORDER SIBLINGS BY line, col
LEVEL LPAD('',2*(LEVEL-1))||NAME OBJECT_TYPE TYPE USAGE LINE
1 T_REC_CAPTION PACKAGE RECORD DECLARATION 317
2 TITLE PACKAGE VARIABLE DECLARATION 318
3 VARCHAR2 PACKAGE CHARACTER DATATYPE REFERENCE 318
2 TOPTITLE PACKAGE VARIABLE DECLARATION 319
3 VARCHAR2 PACKAGE CHARACTER DATATYPE REFERENCE 319
2 SPAN PACKAGE VARIABLE DECLARATION 320
3 PLS_INTEGER PACKAGE SUBTYPE REFERENCE 320
2 COMMENT PACKAGE VARIABLE DECLARATION 321
3 VARCHAR2 PACKAGE CHARACTER DATATYPE REFERENCE 321
2 REPEATTITLE PACKAGE VARIABLE DECLARATION 322
3 BOOLEAN PACKAGE BOOLEAN DATATYPE REFERENCE 322
1 T_REC_CAPTION PACKAGE RECORD REFERENCE 324
2 BINARY_INTEGER PACKAGE SUBTYPE REFERENCE 325
13 Zeilen gewählt
What do you mean with They are giving only one level depth of dependencies? -
I have User1 selecting from table Table2 in user User2 two times in one procedure
- When I select * from DBA_DEPENDENCIES I can only see 1 row although I have 2 calls?
- If I have reference in the declaration section: Table2.columnname%type it does not show in DBA_DEPENDENCIES1- 2 calls to the table means 2 select statment from the same table in the same procedureWhat are you looking for that dba_dependencies doesn't give you?
2- dba_dependencies does not show it where I can find itStill don't know what exactly you are looking for. The reference is shown here:
SQL> create table t (c number);
Table created.
SQL> create or replace
2 procedure p is
3 l_c t.c%type;
4 begin
5 null;
6 end;
7 /
Procedure created.
SQL> select * from user_dependencies;
NAME TYPE REFERENCED_OWNER REFERENCED_NAME REFERENCED_TYPE
P PROCEDURE SELSE T TABLE -
How to find out where a table is used in the code ?
I have a huge database, and I am adding a column to a table...
is there a query to find out if this would impact the code ? I mean I want to find all the places in the code with
insert into mytable, or update mytable.....
how to include both insert into mytable, and update mytable in dba_source ?Use DBA_DEPENDENCIES:
select owner,name,type from dba_dependencies where referenced_name = 'TABLE_NAME'
and referenced_owner = 'TABLE_OWNER';For example:
SQL> select owner,name,type from dba_dependencies where referenced_name = 'EMP'
2 and referenced_owner = 'SCOTT';
OWNER NAME TYPE
PUBLIC TABLE1 SYNONYM
SCOTT SELECT_EMP PROCEDURE
SCOTT EMP_DEPT_VW VIEW
SCOTT PP SYNONYM
SCOTT EMP_MV MATERIALIZED VIEW
SCOTT EMP_VIEW VIEW
6 rows selected.
SQL> However, keep in mind DBA_DEPENDENCIES stores statis references only. If your code references table in question in dynamic SQL you will have to parse DBA_SOURCE and in some cases, even that will not give you all answers.
SY. -
Help with search within pl/sql code
Hi All,
Can you please help me to find all the objects with a database link.
I have some procedures,function and packages which uses database link. I need to fetch all the objects that uses a database link. Is there any way to get the list of object names using any database link?
Thanks in advance
Apppreciate your help!
Thanks
Bobhi there,
the problem with dba_source is that the code might be wrapped.
another possibility is to query dba_dependencies, column referenced_link
Also you can have pl/sql routines that create dynamically code and might use dblinks in their dynamic code.
So you might not be able to be 100 percent complete.
HTH Mathias -
How to find programatically where the iView is present in page layout
Hi all,
I have a iView (Abs Portal comp) in the page which has wideNarow layout . i have a requirement to find where the iView is loaded in the page i.e ) either in Wide column or Narrow column . Based on that i want to reduce/increase the size of the content in the iview.
How to do it ? Any ideas welcome
<b>Thanks</b>
SaravananUse DBA_DEPENDENCIES:
select owner,name,type from dba_dependencies where referenced_name = 'TABLE_NAME'
and referenced_owner = 'TABLE_OWNER';For example:
SQL> select owner,name,type from dba_dependencies where referenced_name = 'EMP'
2 and referenced_owner = 'SCOTT';
OWNER NAME TYPE
PUBLIC TABLE1 SYNONYM
SCOTT SELECT_EMP PROCEDURE
SCOTT EMP_DEPT_VW VIEW
SCOTT PP SYNONYM
SCOTT EMP_MV MATERIALIZED VIEW
SCOTT EMP_VIEW VIEW
6 rows selected.
SQL> However, keep in mind DBA_DEPENDENCIES stores statis references only. If your code references table in question in dynamic SQL you will have to parse DBA_SOURCE and in some cases, even that will not give you all answers.
SY. -
Identifing DMLs on specific database objects in procedure.
Hi,
I'm looking for oracle dictionary views or oracle procedure to identify which DML operations exist in a specific stored procedure. For example,
create or replace procedure test_proc as
i integer;
begin
select count(*) into i from test_table;
end;
I want to identify which DML operation exist on which database object in this test_proc procedure. The answer should be such as, TEST_TABLE ------> SELECT.
How I can solve this problem?
Thanks.Tahnx Karthick, for response.
Yes, I can identify objects used in procedure (from DBA_DEPENDENCIES) but actual matter is identifing whitch dml operation will be done on this objects. I wrote an procedure, witch can show object name and dml name on this object. But my procedure is working with strings (read from DBA_SOURCE), so if there is any variable witch has same name with any table used in procedure, output will be wrong. And there is some applications witch can show object name and DML name on this this object used in a procedure. I am searching how they can achive it. If there is any data dictionary view stores this information?
Thanks
Maybe you are looking for
-
JScrollPane not scrolling to the end of JTable
Hello, I put a table in a scroll pane, and add the scroll pane to a panel. The problem is the scroll pane does not scroll to the end of the table, it always lets me view only the first 37 rows of the table, regardless of how many rows the table actua
-
I've been using a Belkin 6-port Firewire hub for 6 months with no troubles, but in the last week, I suddenly stopped seeing icons on my desktop when I connect. I assumed the hub had gone bad, so I just bought an IOGear 6-port hub to replace. Still am
-
Hi I have recently had to change my BT email password because I got hacked. I can log into my email online no problem with the new password. I've changed the password, in Windows Live Mail but it only works some of the time. Yesterday all emails were
-
Revision: 3140 Author: [email protected] Date: 2008-09-08 09:04:17 -0700 (Mon, 08 Sep 2008) Log Message: Modifying build.xml to include templates in the jar from the new location. Modified Paths: flex/sdk/trunk/modules/antTasks/build.xml
-
Hi! Sorry for my English. I have a Jtable in a Jscrollpane i need block first and second column when i scroll horizontal the jtable. so i can ever see information in this column is possible? Can you help me with an example. THANKS