Skip Headers
Oracle® Application Express Application Builder User's Guide
Release 3.2

E11947-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

Understanding Substitution Strings

You can use substitution strings within a page template or region source to replace a character string with another value. As you design your application and enable users to edit items, you use substitution strings to pass information.

Topics in this section include:

Using Substitution Strings

You can use substitution strings in Application Builder in the following ways:

  • Include a substitution string within a template to reference component values

  • Reference page or application items using &ITEM. syntax

  • Use built-in substitution strings to achieve a specific type of functionality

Special substitution strings available within a template are denoted by the number symbol (#). For example:

#ABC#

To reference page or application items using substitution variables:

  1. Reference the page or application item in all capital letters.

  2. Precede the item name with an ampersand (&).

  3. Append a period (.) to the item name.

For example, you would refer to an application item named F101_X in an HTML region, a region title, an item label, or in any of numerous other contexts in which static text is used, for example:

&F101_X.

Notice the required trailing period. When the page is rendered, Application Express engine replaces value the substitution string with the value of item F101_X.

Determining Substitution String Usage within a Given Template

You can determine what template-specific substitution strings are supported in which templates by viewing the template definition. See "Customizing Templates".

About Built-in Substitution Strings

Application Builder supports a number of built-in substitution strings. You may need to reference these values to achieve specific types of functionality.

The following sections describe these substitution strings, when to use them, and what supported syntax is currently available. Note that bind variable :USER has special meaning within the database. Also, the term Direct PL/SQL refers to PL/SQL that can be used in stored database objects such as procedures and functions.

Topics in this section include:

See Also:

APP_ALIAS

APP_ALIAS is an alphanumeric name for the current application. APP_ALIAS is different from the APP_ID in that the APP_ID must be unique over all workspaces and all applications hosted in one database. In contrast, APP_ALIAS must be unique within a workspace. For example, by using the same APP_ALIAS you can create the application, ABC, in two different workspaces. You can use APP_ALIAS almost anywhere APP_ID can be used. For example, f?p syntax can use an APP_ALIAS or an application ID as demonstrated in this example:

f?p=ABC:1:&APP_SESSION.

This example runs application ABC, page 1 using the current session.

Table 3-4 describes the supported syntax for referencing APP_ALIAS.

Table 3-4 APP_ALIAS Syntax

Reference Type Syntax

Bind variable

:APP_ALIAS

PL/SQL

V('APP_ALIAS')

Substitution string

&APP_ALIAS.


The following is an HTML example:

Click me to go to page 1 <a href="f?p=&APP_ALIAS.:1:&APP_SESSION."> of the current application</a>

APP_ID

APP_ID identifies the application ID of the currently executing application. Table 3-5 describes the supported syntax for referencing APP_ID.

Table 3-5 APP_ID Syntax

Reference Type Syntax

Bind variable

:APP_ID

Direct PL/SQL

APEX_APPLICATION.G_FLOW_ID (A NUMBER)

PL/SQL

NV('APP_ID')

Substitution string

&APP_ID.


The following is an example of a substitution string reference:

f?p=&APP_ID.:40:&APP_SESSION.

APP_IMAGES

Use this substitution string to reference uploaded images, JavaScript, and cascading style sheets that are specific to a given application and are not shared over many applications. If you upload a file and make it specific to an application, then you must use this substitution string, or bind variable. Table 3-6 describes the supported syntax for referencing APP_IMAGES.

Table 3-6 APP_IMAGES Syntax

Reference Type Syntax

Bind variable

:APP_IMAGES

Direct PL/SQL

Not available.

PL/SQL

V('APP_IMAGES')

Substitution string

&APP_IMAGES.

Template substitution

#APP_IMAGES#


APP_PAGE_ID

APP_PAGE_ID is the current application ID. For example, if your application was on page 3, then the result would be 3. Using this syntax is useful when writing application components that need to work generically in multiple applications. Table 3-7 describes the supported syntax for referencing APP_PAGE_ID.

Table 3-7 APP_PAGE_ID Syntax

Reference Type Syntax

Bind variable

:APP_PAGE_ID

PL/SQL

:APP_PAGE_ID

PL/SQL and Direct PL

NV('APP_PAGE_ID')

Substitution string

&APP_PAGE_ID.


The following is an example of a substitution string reference:

f?p=&APP_ID.:&APP_PAGE_ID.:&APP_SESSION.

APP_SESSION

APP_SESSION is one of the most commonly used built-in substitution strings. You can use this substitution string to create hypertext links between application pages that maintain a session state by passing the session number. Note that you can also use the substitution string SESSION in place of APP_SESSION. Table 3-8 describes the supported syntax for referencing APP_SESSION.

Table 3-8 APP_SESSION Syntax

Reference Type Syntax

Bind variable

:APP_SESSION

PL/SQL

V('APP_SESSION')

Short PL/SQL

V('SESSION')

Substitution string

&APP_SESSION.


Consider the following examples:

  • From within an HTML region:

    <a href="f?p=100:5:&APP_SESSION.">click me</a> 
    
  • Using PL/SQL:

    htf.anchor('f?p=100:5:'||V('APP_SESSION'),'click me');
    
  • Using a SQL query:

    SELECT htf.anchor('f?p=100:5:'||:APP_SESSION,'clickme') FROM DUAL;
    

APP_UNIQUE_PAGE_ID

APP_UNIQUE_PAGE_ID is an integer generated from an Oracle sequence which is unique for each page view. This number is used by applications to prevent duplicate page submissions and can be used for other purposes. For example, to make a unique URL and avoid browser caching issues, you can embed this number in the request or debug column in calls to the f procedure. Table 3-9 describes the supported syntax for referencing APP_UNIQUE_PAGE_ID.

Table 3-9 APP_UNIQUE_PAGE_ID Syntax

Reference Type Syntax

Bind variable

:APP_UNIQUE_PAGE_ID

PL/SQL

V('APP_UNIQUE_PAGE_ID')

Substitution string

&APP_UNIQUE_PAGE_ID.


The following is an HTML example:

SELECT 'f?p=100:1:'||:APP_SESSION||':'||:APP_UNIQUE_PAGE_ID||
    ':::P1_EMPNO:'||employee_id,
   first_name,
    job_id
FROM employees

Note the use of the APP_UNIQUE_PAGE_ID in the request column. This makes this URL unique and may avoid excessive browser caching problems.

APP_USER

APP_USER is the current user running the application. Depending upon your authentication model, the value of the user is set differently. If the application is running using database authentication, then the value of the user is the same as the database pseudo column USER. If the application uses an authentication scheme that requires the user to authenticate, the value of APP_USER is set by the authentication scheme, usually to the user name used during authentication. Table 3-10 describes the supported syntax for referencing APP_USER.

Table 3-10 APP_USER Syntax

Reference Type Syntax

Bind variable

:APP_USER

PL/SQL

V('APP_USER')

Substitution string

&APP_USER.


Consider the following examples:

  • From within an HTML region:

    Hello you are logged in as &APP_USER.
    
  • Using PL/SQL:

    htp.p('Hello you are logged in as'||V('APP_USER')); 
    
  • As a bind variable:

    SELECT * FROM some_table WHERE user_id = :APP_USER
    

    See Also:

    "Authentication" for information about the Public User attribute

AUTHENTICATED_URL_PREFIX

This application-level attribute identifies a valid authenticated prefix (that is, a logged in URL prefix). You can use a relative path or a full path beginning with http. This item is useful if your application can be run in both authenticated (logged in) and public (not logged in) modes. You can use AUTHENTICATED_URL_PREFIX to construct a link to an authenticated page. This item is most useful when using basic database authentication because changes to the URL can require authentication. Table 3-11 describes the supported syntax for referencing AUTHENTICATED_URL_PREFIX.

Table 3-11 AUTHENTICATED_URL_PREFIX Syntax

Reference Type Syntax

Bind variable

:AUTHENTICATED_URL_PREFIX

PL/SQL

V('AUTHENTICATED_URL_PREFIX')

Substitution string

&AUTHENTICATED_URL_PREFIX.


BROWSER_LANGUAGE

BROWSER_LANGUAGE refers to the Web browser's current language preference. Table 3-12 describes the supported syntax for referencing BROWSER_LANGUAGE.

Table 3-12 BROWSER_LANGUAGE Syntax

Reference Type Syntax

Bind variable

:BROWSER_LANGUAGE

Direct PL/SQL

APEX_APPLICATION.G_BROWSER_LANGUAGE

PL/SQL

V('BROWSER_LANGUAGE')

Substitution string

:BROWSER_LANGUAGE.

Substitution string

&BROWSER_LANGUAGE.


CURRENT_PARENT_TAB_TEXT

CURRENT_PARENT_TAB_TEXT is most useful in page templates, but is only relevant for applications that use two-level tabs (that is, parent and standard tabs). Use this string to reference the parent tab label. This substitution string enables you to repeat the currently selected parent tab within the page template. Table 3-13 describes the supported syntax for referencing CURRENT_PARENT_TAB_TEXT.

Table 3-13 CURRENT_PARENT_TAB_TEXT Syntax

Reference Type Syntax

Bind variable

Not Available.

Substitution string

&CURRENT_PARENT_TAB_TEXT.


DEBUG

Valid values for the DEBUG flag are Yes or No. Turning debug on shows details about application processing. If you write your own custom code, you may want to generate debug information only if the debug mode is set to Yes. Table 3-14 describes the supported syntax for referencing DEBUG.

Table 3-14 DEBUG Syntax

Reference Type Syntax

Bind variable

:DEBUG

Direct PL/SQL

APEX_APPLICATION.G_DEBUG

PL/SQL

V('DEBUG')

Substitution string

&DEBUG.


The following is an example of a substitution string reference that preserves the current value of DEBUG:

f?p=100:1:&APP_SESSION.::&DEBUG

HOME_LINK

HOME_LINK is the home page of an application. The Application Express engine will redirect to this location if no page is given and if no alternative page is dictated by the authentication scheme's logic. You define the Home Link on the Application Attributes page.

Table 3-15 describes the supported syntax for referencing HOME_LINK.

Table 3-15 HOME_LINK Syntax

Reference Type Syntax

Direct PL/SQL

APEX_APPLICATION.G_HOME_LINK

PL/SQL

V('HOME_LINK')

Template Reference

#HOME_LINK#

Substitution String

&HOME_LINK.


See Also:

"Authentication" for information about the Home Link attribute

LOGIN_URL

Use LOGIN_URL to display a link to a login page for users that are not currently logged in. Table 3-16 describes the supported syntax for LOGIN_URL.

Table 3-16 LOGIN_URL Syntax

Reference Type Syntax

Bind variable

:LOGIN_URL

Direct PL/SQL

APEX_APPLICATION.G_LOGIN_URL

PL/SQL

V('LOGIN_URL')

Substitution string

&LOGIN_URL.

Template Substitution

#LOGIN_URL#


IMAGE_PREFIX

The value of IMAGE_PREFIX determines the virtual path the Web server uses to point to the images directory distributed with Oracle Application Express. To reference uploaded images, use WORKSPACE_IMAGES and APP_IMAGES. Table 3-17 describes the supported syntax for referencing IMAGE_PREFIX.

Table 3-17 IMAGE_PREFIX Syntax

Reference Type Syntax

Bind variable

:IMAGE_PREFIX

Direct PL/SQL

APEX_APPLICATION.G_IMAGE_PREFIX

PL/SQL

V('IMAGE_PREFIX')

Substitution string

&IMAGE_PREFIX.

Template Substitution

#IMAGE_PREFIX#


Application Express SCHEMA OWNER

If you are generating calls to applications from within your PL/SQL code, you may need to reference the owner of the Oracle Application Express schema. The following describes the correct syntax for a direct PL/SQL reference:

APEX_APPLICATION.G_FLOW_SCHEMA_OWNER

You may also use #FLOW_OWNER# to reference this value in SQL queries and PL/SQL (for example, in a region or a process).

PRINTER_FRIENDLY

The value of PRINTER_FRIENDLY determines if the Application Express engine is running in print view mode. This setting can be referenced in conditions to eliminate elements not desired in a printed document from a page. Table 3-18 describes the supported syntax for referencing PRINTER_FRIENDLY.

Table 3-18 PRINTER_FRIENDLY Syntax

Reference Type Syntax

Direct PL/SQL

APEX_APPLICATION.G_PRINTER_FRIENDLY (VARCHAR2 DATATYPE)

PL/SQL

V('PRINTER_FRIENDLY')

Substitution string

&PRINTER_FRIENDLY.


LOGOUT_URL

LOGOUT_URL is an application-level attribute used to identify the logout URL. This is a URL that navigates the user to a logout page or optionally directly logs out a user. To create a logout navigation bar entry, add a trailing period to &LOGOUT_URL (&LOGOUT_URL.). If you are coding a page template, use #LOGOUT_URL#. Table 3-19 describes the supported syntax for referencing LOGOUT_URL.

Table 3-19 LOGOUT_URL Syntax

Reference Type Syntax

Bind variable

:LOGOUT_URL

PL/SQL

V('LOGOUT_URL')

Substitution string

&LOGOUT_URL.

Template substitution

#LOGOUT_URL#


PROXY_SERVER

PROXY_SERVER is an application attribute. The attribute may be used by regions whose source comes from a URL. The following is the correct syntax for a direct PL/SQL reference used when you are writing PL/SQL to access remote Web servers from within the database (for example, when using the utl_http package shipped with the database).

APEX_APPLICATION.G_PROXY_SERVER

PUBLIC_URL_PREFIX

PUBLIC_URL_PREFIX is an application-level attribute that identifies a URL to toggle out of a logged in mode to a public view. Table 3-20 describes the supported syntax for referencing PUBLIC_URL_PREFIX.

Table 3-20 PUBLIC_URL_PREFIX Syntax

Reference Type Syntax

Bind variable

:PUBLIC_URL_PREFIX

PL/SQL

V('PUBLIC_URL_PREFIX')

Substitution string

&PUBLIC_URL_PREFIX.

Template substitution

#PUBLIC_URL_PREFIX#


REQUEST

Each application button sets the value of REQUEST to the name of the button or to the request value attribute associated with the button. This enables accept processing to reference the name of the button when a user clicks it. In the f?p syntax, REQUEST may be set using the fourth argument.

Referencing the Value of REQUEST

REQUEST is typically referenced during Accept processing (that is, the processing that occurs when you post a page). Table 3-21 describes the supported syntax for referencing REQUEST.

Table 3-21 REQUEST Syntax

Reference Type Syntax

Bind variable

:REQUEST

Direct PL/SQL

APEX_APPLICATION.G_REQUEST

PL/SQL

V('REQUEST')

Substitution string

&REQUEST

&REQUEST. (exact syntax match)


Scope and Value of REQUEST for Posted Pages

When you post a page, you initiate Accept processing. Accept processing consists of computations, validations, processes, and branches. The value of REQUEST is available during each phase of the Accept processing. Once an application branches to a different page then REQUEST is set to NULL.

The value of REQUEST is the name of the button the user clicks, or the name of the tab the user selects. For example, suppose you have a button with a name of CHANGE, and a label Apply Change. When a user clicks the button, the value of REQUEST is CHANGE.

About the When Button Pressed Attribute

Validations, processes, and branches have a When Button Pressed attribute. This attribute displays as a select list and contains the names of buttons that exist on the current page. If you make a selection from When Button Pressed, you associate the button's REQUEST value with the validation, process, or branch.

When you use a button to submit a page, the REQUEST value is passed to the page. The Accept processing logic evaluates each validation, process, and branch that uses a When Button Pressed attribute to determine whether the component should run (or fire). When one of these components runs, do not assume that a user actually clicked the associated button and caused the page to be submitted. Keep in mind, that another button using the same request value may have submitted the page. Similarly, JavaScript on the page can also submit the page and pass in a request value.

Referencing REQUEST Using Declarative Conditions

It is common to reference REQUEST using conditions. For example, you may want to reset pagination when a user clicks Go on a report page. You can reset pagination by creating an on-submit page process. The page process can be made conditional using the condition Request = Expression 1.

To conditionalize an on-submit page process:

  1. Under Condition, select the condition type Request = Expression 1.

  2. In Expression 1, enter GO.

Using REQUEST for Show Processing

You can also use REQUEST for Show processing when navigating to a page using f?p syntax. For example:

f?p=100:1:&APP_SESSION.:GO

Remember that the fourth argument in the f?p syntax is REQUEST. This example goes to application 100, page 1 for the current session, and sets the value of REQUEST to GO. Any process or region can reference the value of REQUEST using Show processing.

The following is a similar example using PL/SQL:

IF V ('REQUEST') = 'GO' THEN
   htp.p('hello');
END IF;

Note that htp.p('hello') is a call to a PL/SQL Web Toolkit package to print out the specified text string.

See Also:

SQLERRM

SQLERRM is a template substitution only available in the Applications Region Error Message. The following describes the correct syntax for a region template substitution reference:

#SQLERRM#

SYSDATE_YYYYMMDD

SYSDATE_YYYYMMDD represents the current date on the database server, with the YYYYMMDD format mask applied. You may use this value instead of repeated calls to the SYSDATE() function. The following list describes the supported syntax for referencing SYSDATE_YYYYMMDD.

  • Bind variable

    :SYSDATE_YYYYMMDD
    
  • PL/SQL

    V('SYSDATE_YYYYMMDD')
    
  • Direct PL/SQL

    APEX_APPLICATION.G_SYSDATE (DATE DATATYPE)
    

Table 3-22 SYSDATE_YYYYMMDD Syntax

Reference Type Syntax

Bind variable

:SYSDATE_YYYYMMDD

Direct PL/SQL

APEX_APPLICATION.G_SYSDATE (DATE DATATYPE)

PL/SQL

V('SYSDATE_YYYYMMDD')


WORKSPACE_IMAGES

Use this substitution string to reference uploaded images, JavaScript, and cascading style sheets that are shared over many applications within a workspace. Table 3-23 describes the supported syntax for referencing WORKSPACE_IMAGES.

Table 3-23 WORKSPACE_IMAGES Syntax

Reference Type Syntax

Bind variable

:WORKSPACE_IMAGES

Direct PL/SQL

Not available

PL/SQL

V('WORKSPACE_IMAGES')

Substitution string

&WORKSPACE_IMAGES.

Template substitution

#WORKSPACE_IMAGES#