Professional Documents
Culture Documents
Erdogan Dogdu
Georgia State University
Computer Science Department
edogdu@cs.gsu.edu
http://db.gsu.edu/~edogdu
Content
CSC8711
CSC8711
2.
3.
CSC8711
5.
6.
7.
CSC8711
Invoking mod_plsql
protocol://hostname[:port]/DAD
location/[[!][schema.][package.]proc_
name[?query_string]]
Example:
http://db.gsu.edu:7777/pls/csc8711/simple
CSC8711
HTTP
GET, POST, HEAD methods
GET. Parameters in query string.
http://host:port/pls/DAD/foo?a=v&b=1
CSC8711
A Simple Example
CSC8711
Run procedure:
http://db.gsu.edu:7777/pls/csc8711/simple
CSC8711
Web Toolkit
Oracle Web Toolkit includes a number of
packages:
htp and htf package: hypertext
procedures and functions,
owa_cookie: to handle HTTP cookies,
owa_util: utility subprograms,
etc.
CSC8711
htp package
Example:
create or replace procedure hello AS
BEGIN
htp.htmlopen;
-- generates <HTML>
htp.headopen;
-- generates <HEAD>
htp.title('Hello');
-- generates <TITLE>Hello</TITLE>
htp.headclose;
-- generates </HEAD>
htp.bodyopen;
-- generates <BODY>
htp.header(1, 'Hello'); -- generates <H1>Hello</H1>
htp.bodyclose;
-- generates </BODY>
htp.htmlclose;
-- generates </HTML>
END;
CSC8711
Comment: htp.comment
Applet: htp.appletopen,
List: htp.olistOpen, htp.ulinstOpen,
Form: htp.formOpen,
Table: htp.tableOpen, htp.tableData,
Image: htp.img, etc.
Formatting: htp.print, htp.bold, htp.underline,
Frame: htp.frame,
CSC8711
owa_util
owa_util.tablePrint
create or replace procedure showemps is
ignore_more boolean;
begin
ignore_more := owa_util.tablePrint('emp',
'BORDER', OWA_UTIL.PRE_ TABLE);
end;
owa_util
<PRE>
----------------------------------------------------------------| EMPNO |ENAME |JOB
|MGR
|HIREDATE
| SAL | COMM | DEPTNO |
----------------------------------------------------------------| 7369| SMITH | CLERK
| 7902 | 17-DEC-80 | 800 |
| 20 |
| 7499| ALLEN | SALESMAN| 7698 | 20-FEB-81 | 1600 | 300 | 30 |
| 7521| WARD
| SALESMAN| 7698 | 22-FEB-81 | 1250 | 500 | 30 |
| 7566| JONES | MANAGER | 7839 | 02-APR-81 | 2975 |
| 20 |
| 7654| MARTIN | SALESMAN| 7698 | 28-SEP-81 | 1250 | 1400| 30 |
| 7698| BLAKE | MANAGER | 7839 | 01-MAY-81 | 2850 |
| 30 |
| 7900| JAMES | CLERK
| 7698 | 03-DEC-81 | 950 |
| 30 |
| 7902| FORD
| ANALYST | 7566 | 03-DEC-81 | 3000 |
| 20 |
| 7934| MILLER | CLERK
| 7782 | 23-JAN-82 | 1300 |
| 10 |
----------------------------------------------------------------</PRE>
CSC8711
Passing Parameters
GET method
http://db:7777/pls/csc8711/pl1?str=Hello&num=4
create or replace procedure pl1(str in varchar2, num in
number) as
1. Hello
begin
<br>
for i in 1..num loop
2. Hello
htp.print(i || '. ' || str);
<br>
htp.br;
3. Hello
end loop;
<br>
end;
4. Hello
<br>
CSC8711
HTML Forms
htp.formOpen(curl in varchar2,
cmethod in varchar2 default POST,
ctarget in varchar2, cenctype in
varchar2 default null, cattributes in
varchar2 default null);
<FORM ACTION=curl
METHOD=cmethod
TARGET=ctarget
ENCTYPE=cenctype cattributes>
CSC8711
HTML Forms
htp.formSubmit(cname in varchar2
default null, cvalue in varchar2 default
Submit, cattributes in varchar2 default
null)
<INPUT TYPE=submit
NAME=cname VALUE=cvalue
cattributes>
CSC8711
HTML Forms
CSC8711
HTML Forms
Useful functions:
owa_util.get_owa_service_path: Returns
the prefix of the URL pointing to PL/SQL
procedure
Example:
http://db.gsu.edu:7777/pls/survey/login
CSC8711
CSC8711
CSC8711
CSC8711
Parameter passing
<%@ plsql parameter="varname" %>
CSC8711
CSC8711