Oracle9i Application Server Using the PL/SQL Gateway
Release 1 (v1.0.2.2)

Part Number A90099-01

Contents

Index

Go to previous page Go to next page

6
PL/SQL Gateway Tutorial

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:

6.1 Creating and Loading the Stored Procedure into the Database

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.

  1. Type the following lines and save it in a file called current_users.sql. The current_users procedure retrieves the contents of the all_users table and formats it as an HTML table.

     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.

  2. Start up Server Manager in line mode. ORACLE_HOME is the directory that contains the Oracle database files.

         prompt> $ORACLE_HOME/bin/svrmgrl
    
    
  3. Connect to the database as "scott". The password is "tiger".

    SVRMGR> connect scott/tiger
    
    
  4. Load the current_users stored procedure from the current_users.sql file. You need to provide the full path to the file if you started up Server Manager from a directory different than the one containing the current_users.sql file.

    SVRMGR> @  Name of script file: current_users.sql
  5. Exit Server Manager.

    SVRMGR> exit
    
    
  6. Configure a DAD to point to the schema where the PL/SQL applications that you want to run with the PL/SQL Gateway are stored. Use the parameters shown in the following table:
    Table 6-1 Parameters
    Parameter  Value 

    Database Access Descriptor Name 

    Scott 

    Schema 

    Scott 

    Oracle User Name 

    Scott 

    Oracle Password 

    Tiger 

    Oracle Connect String 

    htmlperf-tcp 

    Authentication Mode 

    Basic 

    Session Cookie Name 

     

    Create a Stateful Session? 

    No 

    Enable Connection Pooling 

    Yes 

    Maximum Number of Worker Threads 

    10 

    Default (Home) Page 

    Scott.home 

    Document Table 

    Scott.wwdoc_document 

    Document Access Path 

    docs 

    Document Access Procedure 

    Scott.wpg_testdoc.process_download 

    Extensions to be Uploaded as LONGRAW 

    Path Alias 

     

    Path Alias Procedure 

     

Note: To require a user to log on to the database containing the application, leave the Oracle User Name and Oracle Password fields blank.

6.2 Creating an HTML Page to Invoke the Application

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.



Go to previous page Go to next page
Oracle
Copyright © 2001 Oracle Corporation.

All Rights Reserved.

Contents

Index