PLSQL Server Pages Web Programming with PLSQL Erdogan
PL/SQL Server Pages (Web Programming with PL/SQL) Erdogan Dogdu Georgia State University Computer Science Department edogdu@cs. gsu. edu http: //db. gsu. edu/~edogdu
Content l Disadvantages of Web Toolkit l PL/SQL Server Pages l Syntax l Loading PSP Pages l Example CSC 8711
Disadvantages of Web Toolkit l PL/SQL Web Toolkit (htp, htf) generates HTML code form PL/SQL programs. l Generating nice web pages is difficult, you cannot author PL/SQL programs in Frontpage. l Solution is PSP (next) CSC 8711
PL/SQL Server Pages (PSP) l Author web pages using script-friendly HTML authoring tools. l Drop in PL/SQL code within HTML code using scripting tag <% %>. l In short: – Web Toolkit: generate HTML from PL/SQL – PSP: embedded PL/SQL within HTML CSC 8711
Syntax of PL/SQL Server Pages l Same script tag syntax as in ASP and JSP: <% … %> l PSP files should have. psp extension l Can be as simple as an HTML page (no PL/SQL script) l Specifying the scripting language <%@ page language="PL/SQL" %> CSC 8711
Syntax of PL/SQL Server Pages l Parameter passing <%@ plsql parameter="varname" %> l Returned document type <%@ page content. Type="MIMEtype" %> Such as text/xml, text/plain, image/jpeg l Stored procedure name <%@ page procedure="procname" %> CSC 8711
Loading PL/SQL Server Pages l Loading psp document to Oracle loadpsp [ -replace ] -username/password[@connect_string] [ include_file_name. . . ] [ error_file_name ] psp_file_name. . . CSC 8711
More Syntax l Statements <% PL/SQL Statement; [ PL/SQL Statement; ] … %> l Expression <%= PL/SQL Expression %> l Conditional blocks <% if condition then %> [HTML code] <% else %> [HTML code] <% end if; %> CSC 8711
More Syntax l Including files <%@ include file="path name" %> l PL/SQL declarations <%! PL/SQL declaration; [ PL/SQL declaration; ]. . . %> CSC 8711
PSP Example: Grade Book First page: get_access. psp Overview: Allows login to application <%@ page language="PL/SQL" %> <%@ plsql procedure="get_access" %> <HTML> <HEAD> <TITLE>Get password</TITLE> <H 1>Grade Book Access Page</H 1> </HEAD> (cont. next slide) CSC 8711
PSP Example: Grade Book <BODY> <FORM ACTION="<%=owa_util. get_owa_service_pat h%>start_session" METHOD="POST"> <BR> Today is <%=to_char(sysdate, 'Day')%>, <%=to_char(sysdate, 'Dd / Mon / YYYY HH: MI AM')%> <BR> (cont. next slide) CSC 8711
PSP Example: Grade Book <TABLE><TR> <TD><STRONG>USER ID: </STRONG></TD> <TD><INPUT TYPE="text" NAME="usid" SIZE="20" MAXLENGTH="50"></TD> </TR> <TD><STRONG>PASSWORD: </STRONG></TD> <TD><INPUT TYPE="password" NAME="passwd" SIZE="20" MAXLENGTH="50"></TD> </TR></TABLE> <INPUT TYPE="submit" VALUE=" Proceed "> <INPUT TYPE="reset" VALUE="Reset"> </FORM></BODY></HTML> CSC 8711
PSP Example: Grade Book CSC 8711
Form Processing create or replace procedure start_session( usid in varchar 2 DEFAULT NULL, passwd in varchar 2 DEFAULT NULL) AS … begin select A. userid, A. password, A. last. Access, A. authority into user_buffer, passwd_buffer, time_buffer, auth_buffer from users A where upper(A. userid)=upper(start_session. usid); … end start_session; CSC 8711 This form processing program does not generate any HTML code. Therefore, we leave it as a PL/SQL program (start_session. sql)
Form Processing in PSP l Example: <%@ page language="PL/SQL" %> <%@ plsql procedure="teacher_menu" %> <%@ plsql parameter="u_access" type="varchar 2" default="null" %> <%@ plsql parameter="userid" type="varchar 2" default="null" %> … CSC 8711
- Slides: 15