At runtime, Oracle Forms automatically establishes and manages a single connection to ORACLE. By default, one user session is created for this connection. However, the multiple-sessioning feature of ORACLE allows a single client to establish multiple sessions within a single connection. ORACLE transaction-management and read-consistency features all are implemented at the session level, so creating multiple sessions allows a single user to have multiple, independent transactions.
Record-locking and read-consistency behavior for two forms in different sessions is the same as it would be for two independent clients with separate connections. When two independent forms access the same table, it is possible for one form to obtain a lock that would prevent the other form from accessing records in the table.
In a multiple-form application, you have the option to create an independent session whenever one form opens another form with the OPEN_FORM procedure. By default, Oracle Forms does not issue a savepoint when you open a form, and the opened form shares the same session as the form from which it was opened.
The following examples open a form without creating a new session, and are equivalent:
OPEN_FORM('stocks'); -- default; NO_SESSION is implicit
OPEN_FORM('stocks',
activate,
no_session) -- NO_SESSION is explicit (for clarity)
To open a form in its own independent session, use the SESSION parameter. This statement opens the STOCKS form in its own session, and sets focus to it immediately:
OPEN_FORM('stocks',
activate,
session);
When a form initiates a COMMIT, Oracle Forms performs validation and commit processing for each open form sharing the same session as the initiating form. Forms are processed in a sequence defined by the order in which they were opened, starting with the form that initiated the COMMIT. If an error occurs during commit processing, Oracle Forms returns input focus to the form that initiated the COMMIT.
When you call OPEN_FORM with the NO_SESSION parameter (the default), Oracle Forms does not issue a savepoint for the form as it does when you use CALL_FORM. If Form A opens Form B, both forms share the same session. If Form B executes CLEAR_FORM (which performs an implicit ROLLBACK), Oracle Forms rolls back all changes made in Form A and Form B.
Creating independent sessions is usually appropriate for forms that access different tables and manage transactions that are logically independent. For example, an order-entry form might have a menu option to invoke an appointment calendar form. If the appointment calendar is opened in the same session as the order-entry form, end users must simultaneously commit changes made to both forms. If the calendar form is opened in a separate session, however, end users can enter a new appointment and save it to the database independently, without having to commit in the order entry form.
Note: Forms Runtime must have the Session option set to On when you execute OPEN_FORM with the session_mode parameter set to SESSION. If the Session option is set to Off, Oracle Forms issues an error and does not open the indicated form. To set the Forms Runtime Session option to On, set the FORMS_SESSION environment variable to TRUE. When you set the FORMS_SESSION variable, all Forms Runtime invocations inherit its setting, unless you override the environment variable by setting the Session option from the Forms Runtime command line.