March 4, 2011

Searching through source code in Oracle Apex repository

In Apex SQL Workshop, there is an option to search through PL/SQL code, but this is limited to code in your database shema, and does not extend to code that you put in your pages.

By snooping around APEX_040000 shema, one can find that apex page code is saved in CLOB format.  We can easily display code that is not longer that 4000 bytes, and if it is, it probably should be put in database package/procedure.

Searching through PL/SQL page processes, in my example for 'mime_type':

 SELECT  application_id,  
      application_name,  
      page_id,  
      page_name,  
      process_name,  
      process_point,  
      DBMS_LOB.SUBSTR (PROCESS_SOURCE, 4000, 1) source  
  FROM  APEX_APPLICATION_PAGE_PROC  
  WHERE  DBMS_LOB.SUBSTR (PROCESS_SOURCE, 4000, 1) LIKE '%mime_type%'  

Searching through PL/SQL shared application processes, in my example for 'mime_type':

 SELECT  application_id,  
      application_name,  
      process_name,  
      DBMS_LOB.SUBSTR (PROCESS, 4000, 1)  
  FROM  APEX_APPLICATION_PROCESSES  
  WHERE  DBMS_LOB.SUBSTR (PROCESS, 4000, 1) LIKE '%mime_type%'  


Searching through Javascript,  in my example for 'getElementById':

 SELECT  application_id,  
      application_name,  
      page_id,  
      page_name,  
      NVL (DBMS_LOB.SUBSTR (JAVASCRIPT_CODE, 4000, 1),  
        DBMS_LOB.SUBSTR (PAGE_HTML_HEADER, 4000, 1))  
       js  
  FROM  APEX_APPLICATION_PAGES  
  WHERE  NVL (DBMS_LOB.SUBSTR (JAVASCRIPT_CODE, 4000, 1),  
        DBMS_LOB.SUBSTR (PAGE_HTML_HEADER, 4000, 1)) LIKE  
       '%getElementById%';  

It would be nice to have this in a easy to call function, or even inside Oracle Apex.

No comments:

Post a Comment