Oracle APEX应用构建器“Search Application”功能实现及可用API咨询
Hey there! Great question about Oracle APEX's Search Application feature. Let's dive into how it works, what options developers have for custom searches, and practical steps to search your application's source text.
How the Built-in "Search Application" Feature Works
At its core, the Search Application tool relies on Oracle APEX's underlying metadata storage. Every component of your APEX application—pages, regions, items, PL/SQL processes, static text, shared components, and more—is stored in a set of database views prefixed with APEX_*.
When you run a search through the built-in tool, APEX executes a behind-the-scenes query that scans these views for your target text. It filters results to only include objects from your current application, then returns matches with context: object type (e.g., "Region", "Process"), location (like page number), and a snippet of the matching content to help you jump directly to the component.
Are There APIs Developers Can Call?
Oracle doesn't offer a dedicated public API to directly invoke the built-in Search Application functionality, but you can replicate (and even extend) its behavior by querying APEX's public metadata views directly. This is exactly what the built-in tool does under the hood.
Here are some of the most useful APEX_* views for searching application source:
APEX_APPLICATION_REGIONS: Stores page region details, including static text and PL/SQL region sourcesAPEX_APPLICATION_PROCESSES: Contains application and page-level PL/SQL processesAPEX_APPLICATION_COMPUTATIONS: Holds computation logic for page/application itemsAPEX_APPLICATION_DYNAMIC_ACTIONS: Includes dynamic action conditions and action definitionsAPEX_APPLICATION_STATIC_CONTENT: Stores standalone static text componentsAPEX_APPLICATION_PLSQL_CODE: Houses shared PL/SQL code snippets (functions, procedures) from your app
Practical Example: Build Your Own Application Source Search
To search for specific text across your application's source, you can create a custom query that unions results from multiple metadata views. Here's a ready-to-use example:
WITH search_results AS ( -- Search page regions (including PL/SQL and static content regions) SELECT 'Region' AS object_type, 'Page ' || page_id || ': ' || region_name AS object_name, source AS matching_content, page_id FROM apex_application_regions WHERE application_id = :APP_ID AND (source LIKE '%' || :SEARCH_TEXT || '%' OR region_name LIKE '%' || :SEARCH_TEXT || '%') UNION ALL -- Search application/page processes SELECT 'Process' AS object_type, CASE WHEN page_id = 0 THEN 'Application Level' ELSE 'Page ' || page_id END || ': ' || process_name AS object_name, process_source AS matching_content, page_id FROM apex_application_processes WHERE application_id = :APP_ID AND process_source LIKE '%' || :SEARCH_TEXT || '%' UNION ALL -- Search computations SELECT 'Computation' AS object_type, 'Page ' || page_id || ': ' || computation_name AS object_name, computation_expression AS matching_content, page_id FROM apex_application_computations WHERE application_id = :APP_ID AND computation_expression LIKE '%' || :SEARCH_TEXT || '%' UNION ALL -- Search dynamic actions SELECT 'Dynamic Action' AS object_type, 'Page ' || page_id || ': ' || dynamic_action_name AS object_name, action_definition AS matching_content, page_id FROM apex_application_dynamic_actions WHERE application_id = :APP_ID AND action_definition LIKE '%' || :SEARCH_TEXT || '%' ) SELECT * FROM search_results ORDER BY object_type, page_id;
How to Use This Query:
- Create a new APEX page with an interactive report.
- Paste the query into the report's source.
- Add a text item named
PXX_SEARCH_TEXT(replaceXXwith your page number) and map it to the:SEARCH_TEXTbind variable. - Add a button to submit the page and trigger the search.
Pro Tips:
- For case-sensitive searches, replace
LIKEwithLIKE BINARY. - Extend the query by adding more
UNION ALLblocks for other component types (e.g., LOVs viaAPEX_APPLICATION_LOVS, authorization schemes viaAPEX_APPLICATION_AUTHORIZATIONS). - For large applications, consider adding Oracle Text indexes to the relevant columns (like
sourceorprocess_source) to speed up searches.
内容的提问来源于stack exchange,提问作者kapiell

