Vous êtes sur la page 1sur 26

DB application development using

PL/SQL Server Pages(PSP)



PL/SQL Server Pages (PSP)
Author web pages using script-friendly HTML
authoring tools.
Drop in PL/SQL code within HTML code using
scripting tag <% %>.
In short:
PSP: embedded PL/SQL within HTML
Syntax of PL/SQL Server Pages
Same script tag syntax as in ASP and JSP: <%
PSP files should have .psp extension
Can be as simple as an HTML page (no PL/SQL
script)
How: The Oracle HTTP Server receives a
PL/SQL Server Page request from a client
browser. Gets data from DB then shows it to
user

Syntax of PL/SQL Server Pages
PSP Element Name Specifies . . .
<%@ page ... %> Page Directive Characteristics of the
PL/SQL server page.
<%@ plsql ... %> Procedure Directive The name of the stored
procedure produced by the
PSP file.
<%! ... %> Declaration Block The declaration for a set of
PL/SQL variables that are
visible throughout the page,
not just within the
next BEGIN/END block.
<% ... %> Code Block A set of PL/SQL statements
to be executed when the
procedure is run.
<%= ... %> Expression Block A single PL/SQL expression,
such as a string, arithmetic
expression, function call, or
combination of these.
Oracle Client R2
http://www.oracle.com/technetwork/database/enterprise-
edition/downloads/112010-win64soft-094461.html
Steps in building PL-SQL server pages
Download the Oracle Client 11g Release2 from
http://www.oracle.com/technetwork/database/enterprise-
edition/downloads/112010-win32soft-098987.html
install the above software, the installation is straightforward
Double click on
load PSP to
activate
Steps in building PL-SQL server pages
Steps in building PL-SQL server pages
Steps in building PL-SQL server pages

Steps in building PL-SQL server pages
Steps in building PL-SQL server pages

Steps in building PL-SQL server pages
Steps in building PL-SQL server pages
Steps in building PL-SQL server pages
Steps in building PL-SQL server pages
Steps in building PL-SQL server pages
TNSNAMES.ORA
Steps in building PL-SQL server pages
HTML/PL-SQL code (Notepad++), the file extension
.psp
Save your code in command prompt current folder
load PSP to your database( we will talk about this
later )
Check if the procedure is created( check this in SQL
developer), otherwise correct errors
Run your PS page using internet browser( we will
learn this)
Dont forget to use VPN for off campus access

PSP_example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<%@page language="PL/SQL"%>
<%@plsql procedure="chapter5_test"%>
<%!club_name sporting_clubs.name%type;%>
<%!club_state sporting_clubs.state%type;%>
<head>
<title>PL/SQL Server Page</title>
</head>
<body>
<div align="center"><p><h1>Mountain Climb</h1></p>
<!-- Navigation Bar Links -->

<hr /></div>
<br> <!-- Start Page Content -->
<%select name,state into club_name,club_state from sporting_clubs
where club_id = 120;%>
<p<%if club_state='MO' then%> align="right" <%else%> align="left"<%end if;%>>
Club <%= club_name%> is good for mountain climbing.</p>
<!-- End Page Content -->
</body>
</html>
Procedure Name
Variables_declartions
html
PL SQL
Comments
How to Load PL-SQL
load chapter5_test
loadpsp -replace -user IS420_AS97172@ORACLE chapter5_test.psp
Procedure created
create or replace
PROCEDURE chapter5_test AS
club_name sporting_clubs.name%type;
club_state sporting_clubs.state%type;
BEGIN NULL;
htp.prn('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
');
<head>
<title>PL/SQL Server Page</title>
</head>
<body>
<div align="center"><p><h1>Mountain Climb</h1></p>
<hr /></div>
<br> <!-- Start Page Content -->
');
select name,state into club_name,club_state from sporting_clubs
where club_id = 120;
htp.prn('
<p');
if club_state='MO' then
htp.prn(' align="right" ');
else
htp.prn(' align="left"');
end if;
htp.prn('>
Club ');
htp.prn( club_name);
htp.prn(' is good for mountain
climbing.</p>
<!-- End Page Content -->
</body>
</html>
');
END;
Chapter5_test
loaded procedure
Running chapter5_test using browser
http://oracle.is.umbc.edu:8080/classpsp/IS420_AS97172.chapter5_test
Tenant_List example
loadpsp -replace -user
IS420_AS97172@ORACLE tenant_list.PSP

Tenant_List example
http://oracle.is.umbc.edu:8080/classpsp/IS420_AS97172.tenant_list
Travel DB

Vous aimerez peut-être aussi