Friday, 12 July 2019

How to seach Oracle Objects for Any Specific string included in its definition

Suppose we need to find the Objects having tables with suffix _TL or Table 'FND_FLEX_VALUES' :

Search in Oracle Objects Definition:-

SELECT DISTINCT owner, 
                name, 
                TYPE 
FROM   all_source 
WHERE  name LIKE 'XX%' 
       --AND OBJECT_TYPE IN ('PACKAGE','PACKAGE BODY','TRIGGER','PROCEDURE','FUNCTION') 
       AND ( Upper(text) LIKE '%\_TL %' ESCAPE '\'  
              OR Upper(text) LIKE '%FND_FLEX_VALUES%' );


Search in Form Personalization Definition:-

SELECT (SELECT ffv.user_form_name 
        FROM   fnd_form_vl ffv 
        WHERE  ffv.form_name = ffC.form_name) Form_Name, 
       FFC.SEQUENCE, 
       FFC.function_name, 
       FFC.description, 
       FFC.trigger_event, 
       FFC.trigger_object, 
       FFC.rule_type, 
       FFC.enabled, 
       FFC.condition 
FROM   fnd_form_custom_rules FFC 
WHERE  ( Upper(condition) LIKE '%\_TL %' ESCAPE '\' 
          OR Upper(condition) LIKE '%FND_FLEX_VALUES%' );  


Search in Value Sets Definition:-

SELECT ffvs.flex_value_set_id, 
       ffvs.flex_value_set_name, 
       ffvs.description                   set_description, 
       ffvs.validation_type, 
       ffvt.value_column_name, 
       ffvt.meaning_column_name, 
       ffvt.id_column_name, 
       ffvt.application_table_name, 
       ffvt.additional_where_clause, 
       (SELECT user_name 
        FROM   fnd_user 
        WHERE  user_id = ffvs.created_by) USER_NAME 
FROM   fnd_flex_value_sets ffvs, 
       fnd_flex_validation_tables ffvt 
WHERE  ffvs.flex_value_set_id = ffvt.flex_value_set_id 
       AND ( ( Upper(ffvt.application_table_name) LIKE '%\_TL %' ESCAPE '\' 
                OR Upper(ffvt.application_table_name) LIKE '%FND_FLEX_VALUES%' ) 
              OR ( Upper(ffvt.additional_where_clause) LIKE '%\_TL %' ESCAPE '\' 
                 ) ) 
       AND ffvs.created_by NOT IN ( -1, --ANONYMOUS  
                                    0, --  SYSADMIN  
                                    122, --  ORACLE12.2.0 
                                    2, --  INITIAL SETUP 
                                    1, --  AUTOINSTALL 
                                    121, --  ORACLE12.1.0 
                                    120--  ORACLE12.0.0 
                                   ); 


Search in View or Trigger Definition:-

STEP1: 

CREATE TABLE xxcns_clob_view 
  ( 
     view_name VARCHAR2(100), 
     text      CLOB, 
     id        NUMBER 
  );

STEP2: 

INSERT INTO xxcns_clob_view 
SELECT trigger_name, 
       To_lob(trigger_body), 
       rownum 
FROM   all_triggers 
WHERE  trigger_name LIKE 'XX%'; 


INSERT INTO xxcns_clob_view 
SELECT view_name, 
       To_lob(text), 
       rownum 
FROM   all_views 
WHERE  view_name LIKE 'XX%'; 

STEP3: 

SELECT view_name trigger_name 
FROM   xxcns_clob_view aa 
WHERE  text LIKE '%\_TL%' ESCAPE '\' 
        OR text LIKE '%\_tl%' ESCAPE '\' 
        OR text LIKE '%FND_LOOKUP_VALUES%'
;

No comments:

Post a Comment