When developing Oracle Forms applications, there are times when you need information about the environment in which your form is running. Instead of hardcoding values or creating custom variables, Oracle provides built-in functions that make this task much easier. One such function is GET_APPLICATION_PROPERTY, which allows you to retrieve details about the Oracle Forms runtime environment.
In this article, we will explore what GET_APPLICATION_PROPERTY is, the types of information it can return, how to use it in your forms with examples, and best practices to follow.
What is GET_APPLICATION_PROPERTY?
GET_APPLICATION_PROPERTY is a built-in function in Oracle Forms that retrieves values about the current runtime environment of the application. It provides developers with details such as the current form name, application type, database connection information, and runtime mode.
This function is read-only, meaning you cannot change these properties using it. Instead, you use it to query and make decisions within your form logic.
Syntax of GET_APPLICATION_PROPERTY
GET_APPLICATION_PROPERTY(property CONSTANT);
- property → The name of the application property you want to retrieve.
- The function returns a
VARCHAR2orNUMBERvalue depending on the property type.
Commonly Used Properties
Oracle Forms provides many application properties that can be retrieved. Below are the most frequently used ones:
- Environment and Application Details
USERNAME→ Returns the Oracle database username of the connected user.CONNECT_STRING→ Returns the current database connect string.APPLICATION→ Shows the name of the running application.
- Form and Session Details
CURRENT_FORM→ Returns the name of the form currently running.FORM_NAME→ Retrieves the form module name.RUN_PRODUCT→ Identifies which Oracle Developer product (like Forms, Reports) is currently running.
- Runtime Environment
MODE→ Indicates whether the form is running inNORMALorENTER-QUERYmode.TERMINAL→ Returns the terminal or client machine identifier.HOST→ Provides the hostname of the connected server.
- Navigation and Transaction Properties
CURRENT_BLOCK→ Returns the name of the current block in focus.CURRENT_ITEM→ Returns the name of the current item where the cursor is placed.
Examples of Using GET_APPLICATION_PROPERTY
Let’s look at some practical uses of this function in Oracle Forms development.
Example 1: Display the Current Username
DECLARE
v_user VARCHAR2(30);
BEGIN
v_user := GET_APPLICATION_PROPERTY(USERNAME);
MESSAGE('You are logged in as: ' || v_user);
MESSAGE(' ');
END;
This retrieves the Oracle username of the person currently connected to the database.
Example 2: Show the Current Form Name
DECLARE
v_form VARCHAR2(50);
BEGIN
v_form := GET_APPLICATION_PROPERTY(CURRENT_FORM);
MESSAGE('Current form: ' || v_form);
MESSAGE(' ');
END;
This helps identify which form is currently running, useful when multiple forms are open.
Example 3: Check the Application Mode
IF GET_APPLICATION_PROPERTY(MODE) = 'ENTER-QUERY' THEN
MESSAGE('Form is in Query Mode. Action not allowed.');
MESSAGE(' ');
RAISE FORM_TRIGGER_FAILURE;
END IF;
This prevents users from performing certain actions while the form is in Query Mode.
Example 4: Get Database Connection String
DECLARE
v_conn VARCHAR2(100);
BEGIN
v_conn := GET_APPLICATION_PROPERTY(CONNECT_STRING);
MESSAGE('Connected to: ' || v_conn);
MESSAGE(' ');
END;
This is useful for debugging or logging connection information.
Benefits of Using GET_APPLICATION_PROPERTY
- Dynamic Control: Makes your form responsive to runtime environment changes.
- Improved User Experience: Provides meaningful messages to users about the session or mode.
- Security and Auditing: Helps log user and connection details for auditing.
- Simplifies Development: Reduces the need for writing custom queries for session data.
- Flexibility: Works with many properties, making it a versatile tool in forms development.
Best Practices
- Use Meaningful Messages
Always present information retrieved fromGET_APPLICATION_PROPERTYin a user-friendly format. - Avoid Excessive Calls
Do not repeatedly call the function in performance-sensitive code. Store values in variables when needed. - Combine with Triggers
Use it within triggers likeWHEN-NEW-FORM-INSTANCE,WHEN-BUTTON-PRESSED, orON-LOGONfor maximum efficiency. - Leverage for Debugging
During development, use it to check runtime values such as form names, modes, or database connections. - Secure Sensitive Data
Be cautious when displaying connection strings or host information to end users. Use them mainly for internal logging.
Conclusion
The GET_APPLICATION_PROPERTY function in Oracle Forms is a powerful way to access runtime information about your application environment, form, and user session. By using it effectively, you can create dynamic and intelligent forms that respond to user actions, provide better feedback, and support secure and efficient workflows.
Whether you are checking the current form, identifying the logged-in user, or restricting actions based on the mode, this function is a valuable tool for every Oracle Forms developer.

