Showing posts with label DBMS_UTILITY. Show all posts
Showing posts with label DBMS_UTILITY. Show all posts

Saturday, September 26, 2020

How to find dependencies of a package/table/view in Oracle (DBA_DEPENDENCIES and DBMS_UTILITY.GET_DEPENDENCY)

 

 

 

 

 

 

                    Before changing a package or procedure or view or table, we use check its dependencies using either of below options. It’s pretty much useful. Hence, shared the same. Hope it helps!!

Table: DBA_DEPENDENCIES

This table contains all basic information about the dependent object at first level. So, if I want to know the direct dependencies of PO_HEADERS_ALL, below query is useful. 

 

Utility: DBMS_UTILITY.GET_DEPENDENCY

This utility is pretty much useful when we want to know the dependencies in multiple level. Like we need data like below, while searching for dependencies of Y object.

  1.  X object is dependent on Y object
  2.  Z object is dependent on X




 

Saturday, September 26, 2020 by Team search · 0

Friday, July 3, 2020

Script to re-compile all invalid custom objects in APPS schema (DBMS_DDL.ALTER_COMPILE & DBMS_UTILITY.COMPILE_SCHEMA)









In this post, we have given a custom package while has below logic

  1. Compiles all invalid custom objects (objects starting with XX%). This will be handy when every time a custom code deployment happens. This ensure all dependent objects are compiled and verified.
  2. Compiles all objects in a schema

API used (invalid Objects only): DBMS_DDL.ALTER_COMPILE

API used (Complete Schema): DBMS_UTILITY.COMPILE_SCHEMA

Package:

CREATE OR REPLACE PACKAGE xxsh_dba_utilities AUTHID CURRENT_USER AS PROCEDURE compile_invalid_apps_objects; PROCEDURE compile_schema (piv_schema_name IN VARCHAR2); END xxsh_dba_utilities; / SHOW ERRORS; CREATE OR REPLACE PACKAGE BODY xxsh_dba_utilities AS ------------------------------------------------------------------- -- PROCEDURE compile_invalid_apps_objects -------------------------------------------------------------------- PROCEDURE compile_invalid_apps_objects AS CURSOR cur_invalid_objects IS SELECT object_name, object_type, owner FROM dba_objects WHERE owner = 'APPS' AND status = 'INVALID' AND object_name like 'XX%' AND object_type IN ('PACKAGE', 'PACKAGE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER', 'VIEW', 'MATERIALIZED VIEW', 'SYNONYM' ); lv_status VARCHAR2(200); BEGIN FOR i IN cur_invalid_objects LOOP BEGIN dbms_output.put_line('Compiling Object named :'||i.object_name); IF i.object_type IN ('VIEW','MATERIALIZED VIEW','SYNONYM') THEN EXECUTE IMMEDIATE 'ALTER '||i.object_type ||' '||i.object_name||' COMPILE'; ELSE dbms_ddl.alter_compile(i.object_type,NULL,i.object_name); END IF; lv_status := NULL; SELECT status INTO lv_status FROM dba_objects WHERE object_name = i.object_name AND object_type = i.object_type; dbms_output.put_line ('Post Compilation Object Status :'||lv_status); EXCEPTION WHEN OTHERS THEN dbms_output.put_line('Unhandled Exception:'||SQLERRM); END; END LOOP; END compile_invalid_apps_objects; ------------------------------------------------------------------- -- PROCEDURE compile_schema -------------------------------------------------------------------- PROCEDURE compile_schema (piv_schema_name IN VARCHAR2) AS ln_check NUMBER; BEGIN SELECT COUNT(1) INTO ln_check FROM dba_users WHERE username = piv_schema_name; IF ln_check > 0 THEN dbms_utility.compile_schema(piv_schema_name); dbms_output.put_line('Schema named ' ||piv_schema_name ||' compiled successfully' ); ELSE dbms_output.put_line('Error: Schema named ' ||piv_schema_name ||' does not exists' ); END IF; END compile_schema; END xxsh_dba_utilities; / SHOW ERRORS;

Calling Script:

SET SERVEROUTPUT ON; BEGIN xxsh_dba_utilities.compile_invalid_apps_objects; END;

Friday, July 3, 2020 by Team search · 0

Saturday, August 4, 2018

Example of DBMS_UTILITY. FORMAT_CALL_STACK (How to get call trace in PLSQL?)











Sometimes, while debugging an undocumented code or analyzing a complex algorithm with multiple packages and calling programs, it’s very helpful if there is a utility to show the entire call trace till the first program which initiated the process. 

For above scenario, Oracle has provided a utility named DBMS_UTILITY.FORMAT_CALL_STACK

In this post, I tried to demonstrate its purpose with simple example. 


Test Procedures:
/*Create the procedure TRY1*/
CREATE OR REPLACE PROCEDURE TRY1
IS
BEGIN
dbms_output.put_line(substr(dbms_utility.format_call_Stack, 1,255));
END;
/

CREATE OR REPLACE PROCEDURE TRY2
IS
BEGIN
/*Call procedure TRY1*/
TRY1;
END;
/

CREATE OR REPLACE PROCEDURE TRY3
IS
BEGIN
/*Call procedure TRY2*/
TRY2;
END;
/

Execution:
 

























  Hope this helps!!





Saturday, August 4, 2018 by Team search · 0

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.