HOST_URL Function

This function returns the URL to the Application Express instance, depending on the option passed.

Syntax

APEX_UTIL.HOST_URL (
    p_option IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;

Parameters

Table 35-64 HOST_URL Parameters

Parameter Description

p_option

Specifies the parts of the URL to include.

Possible values for p_option include:

  • NULL - Return URL up to port number. For example:

    http://myserver.com:7778
  • SCRIPT - Return URL to include script name. For example:

    https://myserver.com:7778/pls/apex/
  • IMGPRE - Return URL to include image prefix. For example:

    https://myserver.com:7778/i/

Example

The following example demonstrates how to use the HOST_URL function to return the URL, including the script name, to the current Application Express instance.

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;