Date post: | 11-Apr-2017 |
Category: |
Technology |
Upload: | thuan-nguyen |
View: | 3,079 times |
Download: | 0 times |
18Copyright © Oracle Corporation, 2001. All rights reserved.
Managing Dependencies
18-2 Copyright © Oracle Corporation, 2001. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:
• Track procedural dependencies• Predict the effect of changing a database object
upon stored procedures and functions• Manage procedural dependencies
18-3 Copyright © Oracle Corporation, 2001. All rights reserved.
Understanding Dependencies
18-4 Copyright © Oracle Corporation, 2001. All rights reserved.
Dependencies
18-5 Copyright © Oracle Corporation, 2001. All rights reserved.
Local Dependencies
18-6 Copyright © Oracle Corporation, 2001. All rights reserved.
Local Dependencies
18-7 Copyright © Oracle Corporation, 2001. All rights reserved.
A Scenario of Local Dependencies
18-8 Copyright © Oracle Corporation, 2001. All rights reserved.
create table aa as select * from locations;create view bb as select * from aa;select object_name, status from USER_OBJECTSwhere object_type IN ('TABLE','VIEW');alter table aa add (cc varchar2(10));select object_name, status from USER_OBJECTSwhere object_type IN ('TABLE','VIEW');desc bbselect * from bb;select object_name, status from USER_OBJECTSwhere object_type IN ('TABLE','VIEW');
18-9 Copyright © Oracle Corporation, 2001. All rights reserved.
Displaying Direct Dependencies by UsingUSER_DEPENDENCIES
SELECT name, type, referenced_name, referenced_typeFROM user_dependenciesWHERE referenced_name IN ('EMPLOYEES','EMP_VW' );
18-10 Copyright © Oracle Corporation, 2001. All rights reserved.
Displaying Direct and IndirectDependencies
1. Run the script utldtree.sql that creates the objects that enable you to display the direct and indirect dependencies.2. Execute the DEPTREE_FILL procedure.
EXECUTE deptree_fill(’FUNCTION’, ’ your USERNAME’,’VALID_DEPTID’)
18-11 Copyright © Oracle Corporation, 2001. All rights reserved.
Multiple-Column Subqueries
SELECT nested_level, type, nameFROM deptreeORDER BY seq#;
DEPTREE View
18-12 Copyright © Oracle Corporation, 2001. All rights reserved.
Another Scenario of Local Dependencies
18-13 Copyright © Oracle Corporation, 2001. All rights reserved.
A Scenario of Local NamingDependencies
18-14 Copyright © Oracle Corporation, 2001. All rights reserved.
Understanding Remote Dependencies
18-15 Copyright © Oracle Corporation, 2001. All rights reserved.
Understanding Remote Dependencies
18-16 Copyright © Oracle Corporation, 2001. All rights reserved.
Concepts of Remote Dependencies
• Remote dependencies are governed by the modechosen by the user:
• TIMESTAMP checking• SIGNATURE checking
18-17 Copyright © Oracle Corporation, 2001. All rights reserved.
Pairwise Comparison Subquery
Setting REMOTE_DEPENDENCIES_MODE:• As an init.ora parameter
REMOTE_DEPENDENCIES_MODE = value• At the system level
ALTER SYSTEM SETREMOTE_DEPENDENCIES_MODE = value
• At the session level ALTER SESSION SET
REMOTE_DEPENDENCIES_MODE = value
18-18 Copyright © Oracle Corporation, 2001. All rights reserved.
Remote Dependencies andTime Stamp Mode
18-19 Copyright © Oracle Corporation, 2001. All rights reserved.
Remote Dependencies andTime Stamp Mode
18-20 Copyright © Oracle Corporation, 2001. All rights reserved.
Remote Procedure B Compilesat 8:00 a.m.
18-21 Copyright © Oracle Corporation, 2001. All rights reserved.
Local Procedure A Compilesat 9:00 a.m.
18-22 Copyright © Oracle Corporation, 2001. All rights reserved.
Execute Procedure A
18-23 Copyright © Oracle Corporation, 2001. All rights reserved.
Remote Procedure B Recompiledat 11:00 a.m.
18-24 Copyright © Oracle Corporation, 2001. All rights reserved.
Execute Procedure A
18-25 Copyright © Oracle Corporation, 2001. All rights reserved.
Signature Mode
• The signature of a procedure is:– The name of the procedure– The datatypes of the parameters– The modes of the parameters
• The signature of the remote procedure is saved inthe local procedure.
• When executing a dependent procedure, thesignature of the referenced remote procedure iscompared.
18-26 Copyright © Oracle Corporation, 2001. All rights reserved.
Recompiling a PL/SQLProgram Unit
Recompilation:• Is handled automatically through implicit run-time
recompilation• Is handled through explicit recompilation with the
ALTER statement
18-27 Copyright © Oracle Corporation, 2001. All rights reserved.
Unsuccessful Recompilation
Recompiling dependent procedures and functions isunsuccessful when:• The referenced object is dropped or renamed• The data type of the referenced column is changed• The referenced column is dropped• A referenced view is replaced by a view with
different columns• The parameter list of a referenced procedure is
modified
18-28 Copyright © Oracle Corporation, 2001. All rights reserved.
Successful Recompilation
Recompiling dependent procedures and functions issuccessful if:• The referenced table has new columns• The data type of referenced columns has not
changed• A private table is dropped, but a public table,
having the same name and structure, exists• The PL/SQL body of a referenced procedure has
been modified and recompiled successfully
18-29 Copyright © Oracle Corporation, 2001. All rights reserved.
Recompilation of Procedures
Minimize dependency failures by:• Declaring records by using the %ROWTYPE
attribute• Declaring variables with the %TYPE attribute• Querying with the SELECT * notation• Including a column list with INSERT statements
18-30 Copyright © Oracle Corporation, 2001. All rights reserved.
Packages and Dependencies
18-31 Copyright © Oracle Corporation, 2001. All rights reserved.
Packages and Dependencies
18-32 Copyright © Oracle Corporation, 2001. All rights reserved.
Summary
In this lesson, you should have learned how to:• Keep track of dependent procedures• Recompile procedures manually as soon as
possible after the definition of a database objectchanges
18-33 Copyright © Oracle Corporation, 2001. All rights reserved.
Practice 18 Overview
This practice covers the following topics:• Using DEPTREE_FILL and IDEPTREE to view
dependencies• Recompiling procedures, functions, and packages