Debugging an Application
This section describes approaches to debugging an application including viewing Debug Mode, enabling SQL tracing, and viewing page reports. It also describes how to manually remove a control or a component to isolate a problem.This section contains the following topics:
-
About Tuning Performance
-
Reviewing Session State
-
Accessing Debug Mode
-
Enabling SQL Tracing and Using TKPROF
-
Monitoring Application and Page Resource Use
-
Viewing Reports
-
Debugging Problematic SQL Queries
-
Removing Controls and Components to Isolate a Problem
About Tuning Performance
For applications having a large number of concurrent users, maintaining optimal performance is critical. To optimize your application's performance, remember to utilize the following features:-
Use bind variables within your application whenever possible. You can
reference session state values using bind variable syntax in SQL
queries and application logic such as PL/SQL executed from processes and
validations. Accessing session state using bind variables is the most
efficient way to reference session state.
-
Include a
#TIMING#
substitution string in the region footer so that you can view the timing of each region.
Reviewing Session State
Many applications are based on data contained within application controls. For example, buttons can display conditionally based on a value stored in session state. You can view current session state for your application by clicking the Session link on the Developer Toolbar.Accessing Debug Mode
Viewing a page in Debug Mode enables you to track what the Application Express engine is doing as it renders a page. You access Debug mode by clicking the Debug link in the Developer Toolbar.
See Also:
"About the Developer Toolbar"You can also use
f?p
syntax to run an application in Debug mode. Simply call the page and set the Debug argument to YES
. For example:f?p=100:1:&APP_SESSION.::YES
See Also:
"Using f?p Syntax to Link Pages"Enabling SQL Tracing and Using TKPROF
Tracing your session can be a very effective way to debug an application. From a database perspective, each page request is a single database session. If you enable SQL tracing, then Oracle Application Express creates a temporary file you can then analyze using the TKPROF utility.You enable SQL tracing in Oracle Application Express by using
f?p
syntax to set the argument p_trace=YES
. For example, to trace the display of page 1 in application 100, you would use the syntax:http:/.../f?p=100:1&p_trace=YESTo use the TKPROF utility:
-
Log in to SQL*Plus as a privileged user.
-
Execute the following statement:
show parameter USER_DUMP_DEST
-
Navigate to the directory in which the trace file is created.
-
Run the TKPROF utility from the operating system prompt using the following syntax:
tkprof filename1 filename2 [waits=yes|no] [sort=option] [print=n] [aggregate=yes|no] [insert=filename3] [sys=yes|no] [table=schema.table] [explain=user/password] [record=filename4] [width=n]
The input and output files are the only required arguments.
-
To view online Help, invoke TKPROF without arguments.
See Also:
"Using Application Tracing Tools" in Oracle Database Performance Tuning Guide for information about using the TKPROF programMonitoring Application and Page Resource Use
Oracle Application Express facilitates the monitoring of resources used by applications and pages by calling the packageDBMS_APPLICATION_INFO
. Whenever the Application Express engine renders or processes a page, the module is set to APEX
and includes the application ID and page number. Once set, you can query the V$SESSION
and V$SQLAREA
views to monitor transactions.Viewing Reports
When isolating an issue within a page, it is important to clearly understand the functions it is performing. To accomplish this goal, Application Builder includes a number of page and application reports.
Viewing Page Reports
To view page reports:-
Navigate to the appropriate Page Definition. See "Accessing a Page Definition".
-
Click one of the following buttons at the top of the Page Definition:
-
Events links to a report that details currently defined page controls and processes. See "About Page Events".
-
Objects displays a list of database objects referenced by the current page. See "About Database Object Dependencies".
-
History displays a history of recently changed pages. See "About History".
-
Events links to a report that details currently defined page controls and processes. See "About Page Events".
Viewing Application Reports
To view application reports:-
On the Workspace home page, click the Application Builder icon.
-
Select an application.
-
On the Tasks list, click Application Reports.
-
Select the type of reports to view:
-
Shared Components reports offer information
on common elements that can display on every page within an
application. Reports are grouped by category including Logic,
Navigation, Security, User Interface, Globalization, and Files. Report
examples include Application Items, Computations, Breadcrumb Entries,
Authentication Schemes, and Shortcuts.
-
Page Components reports offer detailed
information on controls and logic that execute when the page is rendered
(for example, branches, buttons, computations, items, and regions).
-
Activity Reports offer details about
developer activity within the current application. Available reports
include Changes by Developer, Changes by Developer by Day, Chart of
Changes by Developer, Page Performance, and Recent Changes.
-
Cross Application Reports offer information
that apply to multiple applications. Available reports include
Application Attributes, Application Comments, Build Options, Build
Status and Application Status, Page Component Counts, Security Profiles,
Authentication Schemes, and Template Defaults by Application.
-
Shared Components reports offer information
on common elements that can display on every page within an
application. Reports are grouped by category including Logic,
Navigation, Security, User Interface, Globalization, and Files. Report
examples include Application Items, Computations, Breadcrumb Entries,
Authentication Schemes, and Shortcuts.
Debugging Problematic SQL Queries
If your query does not seem to be running correctly, try running it in SQL*Plus, SQL Developer, or in SQL Commands. Any of these approaches will test your query outside the context of your application, making it easier to determine what the problem is.Removing Controls and Components to Isolate a Problem
If you have problems running a page, try removing controls and components one at a time. Using this approach, you can quickly determine which control or component may be the source of your problem. You can disable a control or component by selecting the Condition attribute Never.To remove a control or component using conditional attributes:
-
Navigate to the appropriate Page Definition. See "Accessing a Page Definition".
-
Select the name of the control or component you want to disable.
The appropriate attributes page appears.
-
Scroll down to Condition Type and select Never from the Condition Type list.
-
Click Apply Changes and return to the Page Definition.
-
Try running the page again.
-
Continue to remove controls or components until the page runs correctly.
No comments:
Post a Comment