Oracle9i Application Server Using the PL/SQL Gateway Release 1 (v1.0.2.2) Part Number A90099-01 |
|
This section provides a step-by-step guide on creating a simple application that displays the contents of a database table as an HTML table. The application invokes a stored procedure that calls functions and procedures defined in the PL/SQL Web Toolkit.
This tutorial assumes the following:
A schema is a user account containing as a collection of database objects such as tables, views, procedures, and functions. Each object in the schema can access other objects in the same schema.
The stored procedure that the application invokes is current_users (defined below). The procedure retrieves the contents of the all_users table and formats it as an HTML table.
To create the stored procedure, save the text of the procedure in a file called
current_users.sql, and then run Oracle Server Manager to read and execute the statements in the file.
create or replace procedure current_users AS ignore boolean; BEGIN htp.htmlopen; htp.headopen; htp.title('Current Users'); htp.headclose; htp.bodyopen; htp.header(1, 'Current Users'); ignore := owa_util.tablePrint('all_users'); htp.bodyclose; htp.htmlclose; END; / show errors
This procedure uses functions and procedures from the htp and owa_util packages to generate the HTML page. For example, the htp.htmlopen procedure generates the string
<html>, and htp.title('Current Users') generates <title>Current Users</title>
The owa_util.tablePrint function queries the specified database table, and formats the contents as an HTML table.
prompt> $ORACLE_HOME/bin/svrmgrl
SVRMGR> connect scott/tiger
SVRMGR> @ Name of script file: current_users.sql
SVRMGR> exit
Note: To require a user to log on to the database containing the application, leave the Oracle User Name and Oracle Password fields blank.
To run the current_users procedure, enter the following URL in your browser:
http://<host>:<port>/pls/mydad/scott.current_users
Or you can invoke the procedure from an HTML page. The following HTML page has a link that calls the URL.
<HTML> <HEAD> <title>Current Users</title> </HEAD> <BODY> <H1>Current Users</H1> <p><a href="http://hal.us.oracle.com:9999/simpleApp1/cart1/current_ users">Run current_users</a> </BODY> </HTML>
The figure below shows the source page (the page containing the link that invokes the stored procedure), and the page that is generated by the current_users stored procedure.
|
Copyright © 2001 Oracle Corporation. All Rights Reserved. |
|