### Install APEX Application Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/INSTALL-Procedure.html Example demonstrating how to fetch an application from a remote URL and install it with a new ID and component ID offsets in a specified workspace. ```PL/SQL DECLARE l_source apex_t_export_files; l_info apex_application_install.t_file_info; BEGIN l_source := apex_t_export_files ( apex_t_export_file ( name => 'f100.sql', contents => apex_web_service.make_rest_request ( p_url => 'https://www.example.com/apps/f100.sql', p_http_method => 'GET' ))); apex_util.set_workspace('EXAMPLE'); apex_application_install.generate_application_id; apex_application_install.generate_offset; apex_application_install.install ( p_source => l_source ); END; ``` -------------------------------- ### Example: Fetch and Print Install Information Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_INFO-Function.html This PL/SQL example demonstrates how to fetch an application from a remote URL using apex_web_service.make_rest_request and then use the GET_INFO function to retrieve and print its installation details. ```PL/SQL DECLARE l_source apex_t_export_files; l_info apex_application_install.t_file_info; BEGIN l_source := apex_t_export_files ( apex_t_export_file ( name => 'f100.sql', contents => apex_web_service.make_rest_request ( p_url => 'https://www.example.com/apps/f100.sql', p_http_method => 'GET' ))); l_info := apex_application_install.get_info ( p_source => l_source ); sys.dbms_output.put_line (apex_string.format ( p_message => q'!Type ................. %0 !Workspace ............ %1 !Version .............. %2 !App ID ............... %3 !App Name ............. %4 !Alias ................ %5 !Owner ................ %6 !Build Status ......... %7 !Has Install Script ... %8 !App ID Usage ......... %9 !App Alias Usage ...... %10!', p0 => l_info.file_type, p1 => l_info.workspace_id, p2 => l_info.version, p3 => l_info.app_id, p4 => l_info.app_name, p5 => l_info.app_alias, p6 => l_info.app_owner, p7 => l_info.build_status, p8 => apex_debug.tochar(l_info.has_install_script), p9 => l_info.app_id_usage, p10 => l_info.app_alias_usage, p_prefix => '!' )); END; ``` -------------------------------- ### Example: Install Application and Keep Sessions Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/SET_KEEP_SESSIONS-Procedure.html This example demonstrates how to install an application and preserve its session state using SET_KEEP_SESSIONS. Ensure the workspace is set correctly before calling the procedure. ```PL/SQL BEGIN apex_application_install.set_workspace(p_workspace => 'FRED_PROD'); apex_application_install.set_keep_sessions(p_keep_sessions => true); END; / @f100.sql ``` -------------------------------- ### Example Installation of APEX Full Development Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html This is an example of running apexins.sql with specific tablespace and image directory values. ```sql @apexins.sql SYSAUX SYSAUX TEMP /i/ ``` -------------------------------- ### Example Installation of APEX Runtime Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html This is an example of running apxrtins.sql with specific tablespace and image directory values. ```sql @apxrtins.sql SYSAUX SYSAUX TEMP /i/ ``` -------------------------------- ### Example: Install APEX Full Development Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html Example of running apexins.sql with specific tablespace and image directory values. Ensure the virtual image directory is set to '/i/' for future upgrades. ```SQLcl @apexins.sql SYSAUX SYSAUX TEMP /i/ ``` -------------------------------- ### Example: Install APEX Runtime Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html Example of running apxrtins.sql with specific tablespace and image directory values. Ensure the virtual image directory is set to '/i/' for future upgrades. ```SQLcl @apxrtins.sql SYSAUX SYSAUX TEMP /i/ ``` -------------------------------- ### Get Application Build Status Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_APPLICATION_ADMIN.GET_BUILD_STATUS-Function.html This PL/SQL example demonstrates how to call the GET_BUILD_STATUS function to retrieve the build status for a given application ID. ```sql DECLARE l_application_build_status apex_application_admin.t_build_status; BEGIN l_application_build_status := apex_application_admin.get_build_status ( p_application_id => 100 ); END; ``` -------------------------------- ### Example: Get ALLOW_HOSTNAMES Parameter Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_WORKSPACE_PARAMETER.html This example demonstrates how to retrieve the value of the 'ALLOW_HOSTNAMES' parameter for the 'HR' workspace using the GET_WORKSPACE_PARAMETER procedure and prints the output. ```PL/SQL BEGIN DBMS_OUTPUT.PUT_LINE ( APEX_INSTANCE_ADMIN.GET_WORKSPACE_PARAMETER ( p_workspace => 'HR', p_parameter => 'ALLOW_HOSTNAMES' )); END; ``` -------------------------------- ### Get Application Status Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_APPLICATION_ADMIN.GET_APPLICATION_STATUS-Function.html This example demonstrates how to retrieve the status of application ID 100. It sets the workspace, calls the function, and then checks if the application is available for editing using a predefined constant. ```plsql DECLARE l_app_status apex_application_admin.t_app_status; BEGIN apex_util.set_workspace('YOUR_WORKSPACE_NAME'); l_app_status := apex_application_admin.get_application_status ( p_application_id => 100 ); IF l_app_status = apex_application_admin.c_app_available_with_edit_link THEN dbms_output.put_line(l_app_status); -- your custom code here... END IF; END; ``` -------------------------------- ### Enable Procedure for GET and POST Requests Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/ADD_WEB_ENTRY_POINT-procedure.html This example demonstrates how to enable a specific procedure ('MYSCHEMA.MYPKG.PROC') to be callable via both GET and POST HTTP requests. Ensure the procedure exists and the parsing schema has the necessary execute privileges. ```sql BEGIN apex_instance_admin.add_web_entry_point ( p_name => 'MYSCHEMA.MYPKG.PROC', p_methods => 'GET,POST' ); COMMIT; END; ``` -------------------------------- ### Get Supporting Object Scripts for an Application Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_SUPPORTING_OBJECT_SCRIPT-Function.html This example demonstrates how to set the workspace ID and then retrieve install, upgrade, and deinstall scripts for a specific Oracle APEX application using APEX_UTIL.GET_SUPPORTING_OBJECT_SCRIPT. ```sql declare l_install_script clob; l_upgrade_script clob; l_deinstall_script clob; begin apex_util.set_workspace( p_workspace => 'FRED'); l_install_script := apex_util.get_supporting_object_script( p_application_id => 100, p_script_type => apex_util.c_install_script ); l_upgrade_script := apex_util.get_supporting_object_script( p_application_id => 100, p_script_type => apex_util.c_upgrade_script ); l_deinstall_script := apex_util.get_supporting_object_script( p_application_id => 100, p_script_type => apex_util.c_deinstall_script ); end; ``` -------------------------------- ### Using KEYVAL_NUM to Retrieve Package Variable Value Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/KEYVAL_NUM-Function.html This example demonstrates how to use the KEYVAL_NUM function to get the current value of the apex_utilities.g_val_num package variable. No specific setup is required beyond standard PL/SQL block structure. ```plsql DECLARE VAL NUMBER; BEGIN VAL := APEX_UTIL.KEYVAL_NUM; END; ``` -------------------------------- ### Get Region ID by Static ID Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_REGION.GET_ID-Function-Signature-1.html This example demonstrates how to get the ID of a region using its static ID, application ID, and page ID. Note that the p_dom_static_id is not unique and can raise a 'too_many_rows' error. ```PLSQL DECLARE l_region_id apex_application_page_regions.region_id%type; BEGIN ... l_region_id := apex_region.get_id( p_application_id => 100, p_page_id => 1, p_dom_static_id => 'my_apex_region' ); ... END; ``` -------------------------------- ### Get File Type Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_DATA_PARSER.GET_FILE_TYPE-Function.html This example demonstrates how to use the APEX_DATA_PARSER.GET_FILE_TYPE function to determine the file type of 'test.xlsx'. ```sql DECLARE l_file_type apex_data_parser.t_file_type; BEGIN l_file_type := apex_data_parser.get_file_type( 'test.xlsx' ); END; ``` -------------------------------- ### POST_LOGIN Procedure Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/POST_LOGIN-Procedure.html Demonstrates how to call the POST_LOGIN procedure to authenticate a user with provided credentials. ```SQL apex_authentication.post_login('JOE USER', 'mysecret'); ``` -------------------------------- ### Example: Creating an OAuth Client Credential Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/CREATE_CREDENTIAL-Procedure-Signature-1.html Demonstrates how to create a credential definition for OAuth client credentials. This example also shows how to set the persistent client ID and secret for the created credential. ```PLSQL BEGIN -- first set the workspace apex_util.set_workspace(p_workspace => 'MY_WORKSPACE'); apex_credential.create_credential ( p_credential_name => 'OAuth Login', p_credential_static_id => 'OAUTH_LOGIN', p_authentication_type => apex_credential.C_TYPE_OAUTH_CLIENT_CRED, p_scope => 'email', p_allowed_urls => apex_t_varchar2( 'https://tokenserver.example.com/oauth2/token', 'https://www.oracle.com' ), p_prompt_on_install => false, p_credential_comment => 'Credential for OAuth Login' ); -- should be followed by set_persistent_credentials apex_credential.set_persistent_credentials ( p_credential_static_id => 'OAUTH_LOGIN', p_client_id => 'dnkjq237o8832ndj98098-..', p_client_secret => '1278672tjksaGSDA789312..' ); END; ``` -------------------------------- ### Generate Example Data for 'animal.family' Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_EXAMPLE-Function.html This example demonstrates how to use the GET_EXAMPLE function to retrieve five sample rows for the 'animal.family' friendly name. ```SQL select * from apex_dg_data_gen.get_example( p_friendly_name => 'animal.family'); ``` -------------------------------- ### Get Session Territory Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_SESSION_TERRITORY-Function.html This example demonstrates how to call the APEX_UTIL.GET_SESSION_TERRITORY function and store its return value in a local variable. ```plsql DECLARE VAL VARCHAR2(30); BEGIN VAL := APEX_UTIL.GET_SESSION_TERRITORY; END; ``` -------------------------------- ### Menu Initialization and Options Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/menu.html Demonstrates how to initialize the menu widget with options and how to get or set specific options after initialization. ```APIDOC ## Initialize Menu Initialize the menu with the `useLinks` option specified. ```javascript $( ".selector" ).menu( { useLinks: false } ); ``` ## Get or Set Option `useLinks` Get or set the `useLinks` option after the menu has been initialized. ```javascript // get var value = $( ".selector" ).menu( "option", "useLinks" ); // set $( ".selector" ).menu( "option", "useLinks", false ); ``` ``` -------------------------------- ### Get Session Language Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_SESSION_LANG-Function.html This example demonstrates how to retrieve the session language for the current user and store it in a local variable. ```plsql DECLARE VAL VARCHAR2(5); BEGIN VAL := APEX_UTIL.GET_SESSION_LANG; END; ``` -------------------------------- ### Example of APEX_AUTHENTICATION.LOGIN Usage Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/LOGIN-Procedure.html Demonstrates how to call the LOGIN procedure to authenticate a user with provided credentials. Ensure the username and password are correct for successful authentication. ```sql BEGIN apex_authentication.login ( p_username => 'JOE USER', p_password => 'mysecret' ); END; ``` -------------------------------- ### Get Workspace ID Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_WORKSPACE_ID-Function.html This PL/SQL example demonstrates how to call the GET_WORKSPACE_ID function and store the returned workspace ID in a variable. ```plsql DECLARE l_workspace_id number; BEGIN l_workspace_id := apex_application_install.get_workspace_id; END; ``` -------------------------------- ### Example Key Sequences Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/actions.html Demonstrates how to define sequential keyboard shortcuts, where multiple key combinations or individual keys are pressed in order. This is useful for more complex actions or when single shortcuts are unavailable. ```text Ctrl+F2,G,H ``` ```text C,S ``` ```text C,6 ``` ```text W ``` -------------------------------- ### Get Application Schema Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_SCHEMA-Function.html This PL/SQL example demonstrates how to call the GET_SCHEMA function and store the returned application schema in a variable. ```plsql DECLARE l_schema varchar2(30); BEGIN l_schema := apex_application_install.get_schema; END; ``` -------------------------------- ### Open PWA Install Dialog Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/apex.pwa.html Triggers the PWA installation process. For browsers with automatic installation, it starts the process. For others, it opens a dialog with instructions. Can be invoked programmatically or via specific DOM elements/actions. ```javascript apex.pwa.openInstallDialog(); ``` -------------------------------- ### Import Application Blueprint Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/ADD_BLUEPRINT_FROM_FILE-Procedure.html Example of using ADD_BLUEPRINT_FROM_FILE to import a blueprint from an application file. Ensure the file exists and the application ID is correct. ```plsql DECLARE l_blueprint number; BEGIN apex_dg_data_gen.add_blueprint_from_file (p_filename => 'app/example.json', p_application_id => 145, p_override_name => 'My Application Blueprint', p_replace => false, p_blueprint_id => l_blueprint ); END; ``` -------------------------------- ### Extracting and Inspecting Application Archive Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/UNZIP-Function.html This example demonstrates fetching an application archive from a URL, unzipping it using APEX_EXPORT.UNZIP, and then retrieving information about the contained application using APEX_APPLICATION_INSTALL.GET_INFO. Ensure the necessary packages are accessible. ```PL/SQL DECLARE l_zip blob; l_info apex_application_install.t_file_info; BEGIN l_zip := apex_web_service.make_rest_request_b ( p_url => 'https://www.example.com/apps/f100.zip', p_http_method => 'GET' ); l_info := apex_application_install.get_info ( p_source => apex_export.unzip ( p_source_zip => l_zip ) ); sys.dbms_output.put_line ( apex_string.format ( p_message => q'~ !Type ................. %0 !App Name ............. %1 !~', p0 => l_info.file_type, p1 => l_info.app_name, p_prefix => '!' )); END; ``` -------------------------------- ### Example Usage of APEX_JSON.STRINGIFY Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/STRINGIFY-Function-Signature-5.html This example demonstrates how to use the APEX_JSON.STRINGIFY function to convert an sdo_geometry point to its GeoJSON representation and print it. Ensure SDO_GEOMETRY is installed. ```PLSQL BEGIN sys.htp.p(apex_json.stringify( mdsys.sdo_geometry( 2001, 4326, sdo_point_type( 10, 50, null ), null, null ) ) ); END; ``` -------------------------------- ### Install APEX in an Application Container Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-application-container.html Connect to the application container and run the `apxappcon.sql` script to install APEX. The script accepts four arguments similar to `apexins.sql`, plus a fifth argument for the `APEX_PUBLIC_USER` password during installation. ```sql ALTER SESSION SET CONTAINER = apex_approot1; @apxappcon.sql SYSAUX SYSAUX TEMP /i/ P@ssw0rd! ``` -------------------------------- ### Export Application Source with Checksum Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_APPLICATION_Function.html This example shows the content of an install.sql file generated when exporting application source code along with its checksum. It includes references to other SQL scripts and a final checksum value. ```SQL prompt --install @@application/set_environment.sql @@application/delete_application.sql ...snip... @@application/deployment/buildoptions.sql @@application/end_environment.sql -- Application Checksum SH1:jpcliMUZZDVVBI1MKpyyAfPBDww= ``` -------------------------------- ### Example Wallet Path Configuration Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_INSTANCE_ADMIN.Available-Parameter-Values.html This snippet shows an example of a wallet path configuration. It is used to specify the location of a wallet on the file system. ```text file:/home//wallets ``` -------------------------------- ### Get User Style Preference Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_USER_STYLE-Function.html This example demonstrates how to use the GET_USER_STYLE function to retrieve the theme style preference for a specific user, application, and theme. ```sql select apex_theme.get_user_style( 100, 'ADMIN', 42 ) from dual; ``` -------------------------------- ### Get Application Alias Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_APPLICATION_INSTALL.GET_APPLICATION_ALIAS-Function.html This PL/SQL example demonstrates how to call the GET_APPLICATION_ALIAS function and store its return value. The application alias is limited to 255 characters. ```sql DECLARE l_alias varchar2(255); BEGIN l_alias := apex_application_install.get_application_alias; END; ``` -------------------------------- ### APEX_APPLICATION_INSTALL Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/book-index.html Provides procedures and information for application installation. ```APIDOC ## Import Data Types ### Description Details on importing data types for applications. ### Method `N/A` ### Endpoint `APEX_APPLICATION_INSTALL.Import Data Types` ### Parameters None explicitly documented in this snippet. ### Response None explicitly documented in this snippet. ``` ```APIDOC ## INSTALL procedure ### Description Installs an application. ### Method `PROCEDURE` ### Endpoint `APEX_APPLICATION_INSTALL.INSTALL` ### Parameters None explicitly documented in this snippet. ### Response None explicitly documented in this snippet. ``` -------------------------------- ### Generate AI Response Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_AI.GENERATE-Function-Signature-1.html This PL/SQL example demonstrates how to call the apex_ai.generate function to get a response from a specific Generative AI service identified by 'MY_AI_SERVICE'. ```PL/SQL DECLARE l_response clob; BEGIN l_response := apex_ai.generate( p_prompt => 'What is Oracle APEX', p_service_static_id => 'MY_AI_SERVICE'); END; ``` -------------------------------- ### Setting Session Credentials Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/SET_SESSION_CREDENTIALS-Procedure-Signature-1.html This example demonstrates how to use the SET_SESSION_CREDENTIALS procedure to set credentials for 'Login'. This is typically used for BASIC authentication. ```PLSQL BEGIN apex_credential.set_session_credentials ( p_credential_static_id => 'Login', p_username => 'scott', p_password => 'tiger ); END; ``` -------------------------------- ### Example Usage of APEX_AI.GENERATE Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_AI.GENERATE-Function-Signature-2.html This example demonstrates how to use the APEX_AI.GENERATE function to get a response from an AI service configured with a specific static ID and a user prompt. ```plsql DECLARE l_response clob; BEGIN l_response := apex_ai.generate( p_config_static_id => 'low_code_expert', p_prompt => 'What is Oracle APEX' ); END; ``` -------------------------------- ### Install APEX Runtime Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html Execute this script to install the APEX runtime environment locally in a PDB. Provide the tablespace names for APEX platform and files, the temporary tablespace, and the virtual image directory. ```sql @apxrtins.sql tablespace_apex tablespace_files tablespace_temp images ``` -------------------------------- ### Get Start of Day Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/apex.date.html Returns a Date object representing the start of the day (midnight) for a given date. Defaults to the current date and time if no date is provided. ```javascript var dayStartDate = apex.date.startOfDay( myDate ); // output: "2021-JUN-29 24:00:00" (as date object) ``` -------------------------------- ### Create Table, Insert Metadata, and Create Spatial Index Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/INSERT_GEOM_METADATA-Procedure.html This example demonstrates creating a table, inserting spatial metadata using APEX_SPATIAL.INSERT_GEOM_METADATA, and then creating a spatial index. ```SQL create table cities ( city_id number primary key, city_name varchar2(30), shape mdsys.sdo_geometry ) / begin apex_spatial.insert_geom_metadata ( p_table_name => 'CITIES', p_column_name => 'SHAPE', p_diminfo => SDO_DIM_ARRAY ( SDO_DIM_ELEMENT('X', -180, 180, 1), SDO_DIM_ELEMENT('Y', -90, 90, 1) ), p_srid => apex_spatial.c_wgs_84 ); end; / create index cities_idx_shape on cities(shape) indextype is mdsys.spatial_index / ``` -------------------------------- ### Example of Adding a Menu Entry Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_EXTENSION.ADD_MENU_ENTRY-Procedure.html Demonstrates how to add an extension menu link to a specific workspace using the ADD_MENU_ENTRY procedure. Requires the APEX_ADMINISTRATOR_ROLE. ```sql BEGIN apex_extension.add_menu_entry( p_label => 'Example', p_url => 'https://example.com' p_description => 'This is an example' p_workspace => ' MY_WORKSPACE' ); END; ``` -------------------------------- ### Starting a Workflow with Parameters Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_WORKFLOW.START_WORKFLOW-Function.html Example of how to start a workflow using the START_WORKFLOW function, including setting application ID, static ID, and passing workflow parameters. ```plsql BEGIN l_workflow_id := apex_workflow.start_workflow ( p_application_id => 110, p_static_id => 'REQUISITIONWORKFLOW', p_parameters => apex_workflow.t_workflow_parameters( 1 => apex_workflow.t_workflow_parameter(static_id => 'REQ_DATE', string_value => sysdate), 3 => apex_workflow.t_workflow_parameter(static_id => 'REQ_AMOUNT', string_value => l_req_amount), 4 => apex_workflow.t_workflow_parameter(static_id => 'REQ_ITEM', string_value => l_req_item), 5 => apex_workflow.t_workflow_parameter(static_id => 'REQ_ID', string_value => l_req_id)), p_debug_level => apex_debug_api.c_log_level_info ); END; ``` -------------------------------- ### Install APEX Full Development Environment Source: https://docs.oracle.com/en/database/oracle/apex/24.2/htmig/installing-apex-into-different-pdbs.html Execute this script to install the full APEX development environment locally in a PDB. Provide the tablespace names for APEX platform and files, the temporary tablespace, and the virtual image directory. ```sql @apexins.sql tablespace_apex tablespace_files tablespace_temp images ``` -------------------------------- ### Get Install Script to DBMS_OUTPUT Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_SUPPORTING_OBJECT_SCRIPT-Procedure.html Sets the workspace and then retrieves the installation script for a given application, outputting it to the server output buffer. Ensure 'serveroutput' is enabled before execution. ```SQL set serveroutput on; begin apex_util.set_workspace( p_workspace => 'FRED'); apex_util.get_supporting_object_script( p_application_id => 100, p_script_type => apex_util.c_install_script ); end; ``` -------------------------------- ### Get Workflow Variable Value Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_WORKFLOW.GET_VARIABLE_VALUE-Function.html This example demonstrates how to use the APEX_WORKFLOW.GET_VARIABLE_VALUE function to retrieve the value of a workflow variable named 'NEW_SALARY' for a specific workflow instance. ```plsql BEGIN apex_workflow.get_variable_value( p_instance_id => 1234, p_variable_static_id => 'NEW_SALARY'); END; ``` -------------------------------- ### Generate PDF Document Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_PRINT.GENERATE_DOCUMENT-Function-Signature-2.html This example demonstrates how to generate a PDF document using a report query and layout defined in an APEX application, then downloads it. ```PL/SQL DECLARE l_document blob; BEGIN l_document := apex_print.generate_document ( p_application_id => 100, p_report_query_static_id => 'MY_REPORT_QUERY', p_report_layout_static_id => 'MY_REPORT_LAYOUT', p_output_type => apex_print.c_output_pdf ); apex_http.download( p_blob => l_document, p_content_type => 'application/pdf', p_filename => 'my-report.pdf' ); END; ``` -------------------------------- ### Example Usage of CREATE_SESSION Procedure Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/CREATE_SESSION-Procedure.html This example demonstrates how to create a session for a specific user and application, and then prints the application ID and session ID. This procedure is not supported in SQL Workshop tools. ```sql begin apex_session.create_session ( p_app_id => 100, p_page_id => 1, p_username => 'EXAMPLE_USER' ); sys.dbms_output.put_line ( 'App is '||v('APP_ID')||', session is '||v('APP_SESSION')); end; ``` -------------------------------- ### Preserve Background Executions During Installation Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/SET_KEEP_BACKGROUND_EXECS-Procedure.html Example of how to set the workspace and preserve background executions before installing an application. This is useful when you want to ensure that scheduled background jobs are not lost during an application upgrade. ```sql BEGIN apex_application_install.set_workspace(p_workspace => 'FRED_PROD'); apex_application_install.set_keep_background_execs(p_keep_background_execs => true); END; / @f100.sql ``` -------------------------------- ### Create Human Task Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_HUMAN_TASK.CREATE_TASK-Function.html This example demonstrates creating a requisition item and then a human task for its approval using APEX_HUMAN_TASK.CREATE_TASK. It shows how to populate task parameters and set initiator options. ```plsql DECLARE l_req_id number; l_req_item varchar2(100) := 'Some requisition item requiring approval'; l_req_amount number := 2499.42; l_task_id number; BEGIN insert into requisitions(created_by, creator_emailid, item, item_amount, item_category) values (:emp_uid, :emp_email, l_req_item, l_req_amount, 'Equipment') returning id into l_req_id; commit; l_task_id := apex_approval.create_task( p_application_id => 110, p_task_def_static_id => 'REQAPPROVALS', p_subject => 'Requisition ' || l_req_id || ': ' || l_req_item || ' for ' || l_req_amount, p_initiator => :emp_uid, p_initiator_can_complete => true, p_parameters => apex_approval.t_task_parameters( 1 => apex_approval.t_task_parameter(static_id => 'REQ_DATE', string_value => sysdate), 3 => apex_approval.t_task_parameter(static_id => 'REQ_AMOUNT', string_value => l_req_amount), 4 => apex_approval.t_task_parameter(static_id => 'REQ_ITEM', string_value => l_req_item), 5 => apex_approval.t_task_parameter(static_id => 'REQ_ID', string_value => l_req_id) ), p_detail_pk => l_req_id ); END; ``` -------------------------------- ### IconList Initialization and Options Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/iconList.html Demonstrates how to initialize the IconList widget with various options and how to get or set these options after initialization. ```APIDOC ## IconList Initialization and Options This section covers the initialization of the IconList widget and the management of its configuration options. ### Options #### itemSelector :boolean|string This option only applies to the type to select feature. It is a jQuery selector for finding the label text of an item or true to use the text of the item or false to disable type to search. ##### Type: * boolean | string Default Value: * true ##### Examples Initialize the iconList with the itemSelector option specified. ```javascript $( ".selector" ).iconList( { itemSelector: true } ); ``` Get or set option itemSelector after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "itemSelector" ); // set $( ".selector" ).iconList( "option", "itemSelector", true ); ``` #### label :boolean|string This option only applies to the type to select feature. It is a jQuery selector for finding the label text of an item or true to use the text of the item or false to disable type to search. ##### Type: * boolean | string Default Value: * true ##### Examples Initialize the iconList with the label option specified. ```javascript $( ".selector" ).iconList( { label: "myIconLabel" } ); ``` Get or set option label after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "label" ); // set $( ".selector" ).iconList( "option", "label", false ); ``` #### multiple :boolean If true multiple items can be selected. If false at most one item can be selected. Must be false when navigation option is true. ##### Type: * boolean Default Value: * false ##### Examples Initialize the iconList with the multiple option specified. ```javascript $( ".selector" ).iconList( { multiple: true } ); ``` Get or set option multiple after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "multiple" ); // set $( ".selector" ).iconList( "option", "multiple", true ); ``` #### navigation :boolean When true changes the mode of widget to navigation otherwise the mode is selection. This option can't be changed after create. ##### Type: * boolean Default Value: * false ##### Examples Initialize the iconList with the navigation option specified. ```javascript $( ".selector" ).iconList( { navigation: true } ); ``` Get or set option navigation after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "navigation" ); // set $( ".selector" ).iconList( "option", "navigation", true ); ``` #### noNavKeyContent :string A jQuery selector that identifies item content that uses navigation keys or contains elements that use navigation keys. Navigation keys are used to change the focus or selection state, they include the arrow keys, Home, End, Space and Enter as well as keys used in the type to select feature. When the iconList contains tabbable content (iconList#tabbableContent is a valid selector) that can also take keyboard input, such as an `` element this option is used to allow the specified elements to use the navigation keys usually used by the iconList. This is ignored when iconList#navigation is true. ##### Type: * string Default Value: * null ##### Examples Initialize the iconList with the noNavKeyContent option specified. ```javascript $( ".selector" ).iconList( { noNavKeyContent: "input" } ); ``` Get or set option noNavKeyContent after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "noNavKeyContent" ); // set $( ".selector" ).iconList( "option", "noNavKeyContent", "input" ); ``` #### tabbableContent :string A jQuery selector that identifies item content that can be a tab stop when an item has focus. This is ignored when iconList#navigation is true. ##### Type: * string Default Value: * null ##### Examples Initialize the iconList with the tabbableContent option specified. ```javascript $( ".selector" ).iconList( { tabbableContent: "a,button" } ); ``` Get or set option tabbableContent after initialization. ```javascript // get var value = $( ".selector" ).iconList( "option", "tabbableContent" ); // set $( ".selector" ).iconList( "option", "tabbableContent", "a,button" ); ``` ``` -------------------------------- ### Get Proxy Server Attribute Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_PROXY-Function.html This PL/SQL example demonstrates how to use the APEX_APPLICATION_INSTALL.GET_PROXY function to retrieve the proxy server attribute. The attribute value must not exceed 255 characters. ```sql DECLARE l_proxy varchar2(255); BEGIN l_proxy := apex_application_install.get_proxy; END; ``` -------------------------------- ### Example: Using FREE_OUTPUT with CLOB Output Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/FREE_OUTPUT-Procedure.html This example demonstrates initializing CLOB output, generating JSON, printing it, and then freeing the CLOB resources using FREE_OUTPUT. ```sql BEGIN apex_json.initialize_clob_output; apex_json.open_object; apex_json.write('hello', 'world'); apex_json.close_object; dbms_output.put_line(apex_json.get_clob_output); apex_json.free_output; END; ``` -------------------------------- ### GET_EXAMPLE Function Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_DG_DATA_GEN.html Retrieves an example related to data generation. Requires an APEX session. ```APIDOC ## GET_EXAMPLE Function ### Description Retrieves an example, likely of generated data or a blueprint configuration. This function is part of the APEX_DG_DATA_GEN package and requires an active APEX session. ### Signature `APEX_DG_DATA_GEN.GET_EXAMPLE` ### Parameters This function does not explicitly list parameters in the provided documentation. Refer to APEX_DG_DATA_GEN documentation for details on any implicit parameters or required session context. ``` -------------------------------- ### Retrieve Scheduler Job Name Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_AUTOMATION_GET_SCHEDULER_JOB_NAME-Function.html This example demonstrates how to use the APEX_AUTOMATION.GET_SCHEDULER_JOB_NAME function to get the scheduler job name for an automation. It requires specifying the application ID and the static ID of the automation. ```PL/SQL BEGIN dbms_output.put_line( apex_automation.get_scheduler_job_name( p_application_id => 152, p_static_id => 'my_emp_table_automation' ) ); -- ==> APEX$AUTOMATION_2167837869128719 END; ``` -------------------------------- ### Grid Initialization and Options Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aexjs/grid.html Demonstrates how to initialize the APEX Grid component with basic configuration and showcases various options for customizing its behavior, such as aggregate labels, tooltips, and editability controls. ```APIDOC ## Grid Initialization and Options ### Description This section details the initialization of the APEX Grid component and its configurable options. The grid can be initialized with a model and column definitions, and its behavior can be further customized using a variety of options. ### Options #### aggregateLabels :Object Map of aggregate name to object with aggregate label and overallLabel. ##### Type: * Object ##### Properties: Name | Type | Description ---|---|--- `*` | Object | The aggregate name. The model metadata model.RecordMetadata `agg` property is the key to this aggregate map. ###### Properties | Name | Type | Description ---|---|--- `label` | string | The aggregate label. `overallLabel` | string | The aggregate overall label. Default Value: * {} ##### Examples Initialize the grid with the aggregateLabels option specified. ```javascript $( ".selector" ).grid( { aggregateLabels: { SUM: { label: "Sum", overallLabel: "Overall Sum" }, ... } } ); ``` Get or set option aggregateLabels after initialization. ```javascript // get var value = $( ".selector" ).grid( "option", "aggregateLabels" ); // set $( ".selector" ).grid( "option", "aggregateLabels", {...} ); ``` #### aggregateTooltips :Object Map of + "|" + to tooltip text. ##### Type: * Object ##### Properties: Name | Type | Description ---|---|--- `*` | string | The property name is an aggregate name and column name separated with a "|" character. The value is the tooltip text. Default Value: * {} ##### Examples Initialize the grid with the aggregateTooltips option specified. ```javascript $( ".selector" ).grid( { aggregateTooltips: { "AVG|SALARY": "Average Salary", .... } } ); ``` Get or set option aggregateTooltips after initialization. ```javascript // get var value = $( ".selector" ).grid( "option", "aggregateTooltips" ); // set $( ".selector" ).grid( "option", "aggregateTooltips", {...} ); ``` #### allowCopy :boolean If true the selection can be copied to the clipboard using the browsers copy event. This can only be set at initialization time. ##### Type: * boolean Default Value: * true ##### Example Initialize the grid with the allowCopy option specified. ```javascript $( ".selector" ).grid( { allowCopy: false } ); ``` #### allowDelete :boolean Only applies if grid#editable is true. If false then can't use Delete key to delete a row. This only affects the keyboard behavior. The model determines if rows can be deleted or not. ##### Type: * boolean Default Value: * true ##### Examples Initialize the grid with the allowDelete option specified. ```javascript $( ".selector" ).grid( { allowDelete: false } ); ``` Get or set option allowDelete after initialization. ```javascript // get var value = $( ".selector" ).grid( "option", "allowDelete" ); // set $( ".selector" ).grid( "option", "allowDelete", false ); ``` #### allowEditMode :boolean Only applies if grid#editable is true. If false then can't go in or out of edit mode using mouse or keyboard. ##### Type: * boolean Default Value: * true ##### Examples Initialize the grid with the allowEditMode option specified. ```javascript $( ".selector" ).grid( { allowEditMode: false } ); ``` Get or set option allowEditMode after initialization. ```javascript // get var value = $( ".selector" ).grid( "option", "allowEditMode" ); // set $( ".selector" ).grid( "option", "allowEditMode", false ); ``` #### allowInsert :boolean Only applies if grid#editable is true. If false then can't use Insert key to add a row. This only affects the keyboard behavior. The model determines if rows can be added or not. ##### Type: * boolean Default Value: * true ##### Examples Initialize the grid with the allowInsert option specified. ```javascript $( ".selector" ).grid( { allowInsert: false } ); ``` Get or set option allowInsert after initialization. ```javascript // get var value = $( ".selector" ).grid( "option", "allowInsert" ); // set $( ".selector" ).grid( "option", "allowInsert", false ); ``` #### allowSelectHidden :boolean Normally hidden rows cannot be selected. This means that range selection across collapsed control breaks will not select any collapsed rows and if a control break is collapsed any selected rows within it are unselected. Setting this option to true will allow hidden rows to be selected. ##### Type: * boolean Default Value: * false ``` -------------------------------- ### Get APEX Instance URL with Script Name Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/HOST_URL-Function.html This example demonstrates how to use the HOST_URL function with the 'SCRIPT' option to get the URL including the script name. This is useful for constructing full application URLs. ```plsql declare l_host_url varchar2(4000); l_url varchar2(4000); l_application varchar2(30) := 'f?p=100:1'; l_email_body varchar2(32000); begin l_host_url := apex_util.host_url('SCRIPT'); l_url := l_host_url||l_application; l_email_body := 'The URL to the application is: '||l_url; end; ``` -------------------------------- ### Create Cloud Credential Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/CREATE_CLOUD_CREDENTIAL-Procedure.html Example of how to create a new cloud credential named 'MY_CREDENTIAL' using the CREATE_CLOUD_CREDENTIAL procedure. ```sql BEGIN APEX_INSTANCE_ADMIN.CREATE_CLOUD_CREDENTIAL ( p_credential_name => 'MY_CREDENTIAL', p_user_ocid => 'ocid1.user.oc1...', p_tenancy_ocid => 'ocid1.tenancy.oc1..', p_private_key => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', p_fingerprint => '12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef' ); END; ``` -------------------------------- ### Get Contacts Function Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/TABLE_TO_STRING-Function.html Example of creating a function that uses TABLE_TO_STRING to return a comma-delimited string of contact names for a given customer ID. This function is deprecated and JOIN or JOIN_CLOB should be used instead. ```plsql create or replace function get_contacts ( p_cust_id in number ) return varchar2 is l_vc_arr2 apex_application_global.vc_arr2; l_contacts varchar2(32000); BEGIN select contact_name bulk collect into l_vc_arr2 from contacts where cust_id = p_cust_id order by contact_name; l_contacts := apex_util.table_to_string ( p_table => l_vc_arr2, p_string => ', '); return l_contacts; END get_contacts; ``` -------------------------------- ### Example: Creating a Collection from EMP Table Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/CREATE_COLLECTION_FROM_QUERY_B-Procedure.html This example demonstrates how to create a collection named 'EMPLOYEES' and populate it with data from the 'EMP' table using the CREATE_COLLECTION_FROM_QUERY_B procedure. It shows how to define the query and provide bind variable values. ```plsql DECLARE l_query varchar2(4000); BEGIN l_query := 'select empno, ename, job, sal from emp where deptno = :b1'; APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B ( p_collection_name => 'EMPLOYEES', p_query => l_query, p_names => apex_util.string_to_table('b1'), p_values => apex_util.string_to_table('10')); END; ``` -------------------------------- ### Get Application ID Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_APPLICATION_ID-Function.html This PL/SQL example demonstrates how to call the GET_APPLICATION_ID function and store the returned application ID in a local variable. This is useful for programmatic access to the current application's ID. ```plsql DECLARE l_id number; BEGIN l_id := apex_application_install.get_application_id; END; ``` -------------------------------- ### Generate PDF Document Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_PRINT.GENERATE_DOCUMENT-Function-Signature-1.html Example demonstrating how to generate a PDF document using an uploaded template and custom JSON data with the APEX_PRINT.GENERATE_DOCUMENT function. ```PL/SQL DECLARE l_template blob; l_data sys.json_object_t := sys.json_object_t(); l_document blob; BEGIN SELECT blob_content INTO l_template FROM apex_application_temp_files WHERE name = :P1_TEMPLATE; l_data.put( 'name', 'Scott' ); l_document := apex_print.generate_document( p_data => l_data.to_clob, p_template => l_template ); END; ``` -------------------------------- ### Using FIND_WORKSPACE to Get Workspace Name Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/FIND_WORKSPACE-Function.html This example demonstrates how to use the FIND_WORKSPACE function to retrieve the name of a workspace given its security group ID. The security group ID '20' is used in this example. ```plsql DECLARE VAL VARCHAR2(255); BEGIN VAL := APEX_UTIL.FIND_WORKSPACE (p_security_group_id =>'20'); END; ``` -------------------------------- ### Example: Displaying Feedback Follow-ups Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_FEEDBACK_FOLLOW_UP-Function.html This PL/SQL example demonstrates how to retrieve and display all follow-ups for a given feedback ID using the GET_FEEDBACK_FOLLOW_UP function. It iterates through each follow-up and prints it using a custom template. ```plsql declare l_feedback_count number; begin select count(*) into l_feedback_count from apex_team_feedback_followup where feedback_id = 123; for i in 1..l_feedback_count loop htp.p(apex_util.get_feedback_follow_up ( p_feedback_id => 123, p_row => i, p_template => '
#FOLLOW_UP# was created on #CREATED_ON# by #CREATED_BY#') ); end loop; end; / ``` -------------------------------- ### Get Last Viewed Report ID Example Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_IG-GET_LAST_VIEWED_REPORT_ID-Function.html This example demonstrates how to use the GET_LAST_VIEWED_REPORT_ID function to retrieve the last viewed report ID for a specific interactive grid region on a given APEX page. ```plsql DECLARE l_report_id number; BEGIN l_report_id := APEX_IG.GET_LAST_VIEWED_REPORT_ID ( p_page_id => 1, p_region_id => 3335704029884222); END; ``` -------------------------------- ### Example of SET_FIRST_NAME Procedure Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/SET_FIRST_NAME-Procedure.html This example demonstrates how to set the first name for a user using the SET_FIRST_NAME procedure. It requires administrative privileges. ```sql BEGIN APEX_UTIL.SET_FIRST_NAME( p_userid => APEX_UTIL.GET_USER_ID('FRANK'), p_first_name => 'FRANK'); END; ``` -------------------------------- ### Example of Inline Settings in Quick SQL Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeutl/configuring-quick-sql-settings.html This snippet shows the structure of Quick SQL shorthand with inline settings specified. It includes sample data and a non-default options block. ```sql -- Generated by Quick SQL undefined 12/7/2023, 12:20:47 PM /* departments /insert 4 name /nn location country employees /insert 14 name /nn vc50 email /lower cost center num date hired job vc255 view emp_v departments employees --- Non-default options: # settings = {"apex":"Y","db":"19c"} */ ``` -------------------------------- ### Get Application Offset Value Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/GET_OFFSET-Function.html This example demonstrates how to retrieve the application offset value using the GET_OFFSET function. ```plsql DECLARE l_offset number; BEGIN l_offset := apex_application_install.get_offset; END; ``` -------------------------------- ### Example: Plugin Fetch Procedure Using MAKE_REST_REQUEST Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/MAKE_REST_REQUEST-Procedure-Signature-2.html Demonstrates a simplified plugin 'fetch' procedure that utilizes APEX_PLUGIN_UTIL.MAKE_REST_REQUEST to perform an HTTP request. This example shows how to retrieve REST Data Source metadata and pass it to the procedure. ```PL/SQL procedure plugin_fetch( p_plugin in apex_plugin.t_plugin, p_web_source in apex_plugin.t_web_source, p_params in apex_plugin.t_web_source_fetch_params, p_result in out nocopy apex_plugin.t_web_source_fetch_result ) is l_web_source_operation apex_plugin.t_web_source_operation; BEGIN l_web_source_operation := apex_plugin_util.get_web_source_operation( p_web_source => p_web_source, p_db_operation => apex_plugin.c_db_operation_fetch_rows, p_perform_init => true ); p_result.responses.extend( 1 ); apex_plugin_util.make_rest_request( p_web_source_operation => l_web_source_operation, -- p_response => p_result.responses( 1 ), p_response_parameters => p_result.out_parameters ); END plugin_fetch; ``` -------------------------------- ### Example: Get Current Workflow State Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/APEX_WORKFLOW.GET_WORKFLOW_STATE-Function.html Demonstrates how to call the GET_WORKFLOW_STATE function to retrieve the state of a workflow instance. ```plsql BEGIN return apex_workflow.get_workflow_state( p_instance_id => 1234); END; ``` -------------------------------- ### Example: Create Language Mapping for an APEX Application Source: https://docs.oracle.com/en/database/oracle/apex/24.2/aeapi/CREATE_LANGUAGE_MAPPING-Procedure.html Demonstrates how to create a language mapping for an existing APEX application, including setting the workspace context and verifying the creation. ```PL/SQL BEGIN -- -- If running from SQLcl, we need to set the environment -- for the Oracle APEX workspace associated with this schema. -- The call to apex_util.set_security_group_id is not necessary -- if you're running within the context of the App Builder -- or an APEX application. -- FOR c1 IN (select workspace_id from apex_workspaces) loop apex_util.set_security_group_id( c1.workspace_id ); EXIT; END LOOP; -- Now, actually create the language mapping apex_lang.create_language_mapping( p_application_id => 63969, p_language => 'ja', p_translation_application_id => 778899 ); COMMIT; -- -- Print what we just created to confirm -- FOR c1 IN (select * from apex_application_trans_map where primary_application_id = 63969) loop dbms_output.put_line( 'translated_application_id: ' || c1.translated_application_id ); dbms_output.put_line( 'translated_app_language: ' || c1.translated_app_language ); END LOOP; END; / ```