Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / PL_SQL / b14261.pdf
Скачиваний:
27
Добавлен:
12.05.2015
Размер:
4.36 Mб
Скачать

Using PL/SQL to Create Web Applications and Server Pages

Using PL/SQL to Create Web Applications and Server Pages

You can use PL/SQL to develop Web applications or server pages. These are briefly described in this section. For detailed information on using PL/SQL to create Web applications, see "Developing Applications with the PL/SQL Web Toolkit" in Oracle Database Application Developer's Guide - Fundamentals. For detailed information on using PL/SQL to create Web Server Pages (PSPs), see "Developing PL/SQL Server Pages" in Oracle Database Application Developer's Guide - Fundamentals.

PL/SQL Web Applications

With PL/SQL you can create applications that generate Web pages directly from an Oracle database, allowing you to make your database available on the Web and make back-office data accessible on the intranet.

The program flow of a PL/SQL Web application is similar to that in a CGI Perl script. Developers often use CGI scripts to produce Web pages dynamically, but such scripts are often not optimal for accessing Oracle Database. Delivering Web content with PL/SQL stored procedures provides the power and flexibility of database processing. For example, you can use DML, dynamic SQL, and cursors. You also eliminate the process overhead of forking a new CGI process to handle each HTTP request.

You can implement a Web browser-based application entirely in PL/SQL with PL/SQL Gateway and the PL/SQL Web Toolkit.

PL/SQL gateway enables a Web browser to invoke a PL/SQL stored procedure through an HTTP listener. mod_plsql, one implementation of the PL/SQL gateway, is a plug-in of Oracle HTTP Server and enables Web browsers to invoke PL/SQL stored procedures.

PL/SQL Web Toolkit is a set of PL/SQL packages that provides a generic interface to use stored procedures called by mod_plsql at runtime.

PL/SQL Server Pages

PL/SQL Server Pages (PSPs) enable you to develop Web pages with dynamic content. They are an alternative to coding a stored procedure that writes out the HTML code for a web page, one line at a time.

Using special tags, you can embed PL/SQL scripts into HTML source code. The scripts are executed when the pages are requested by Web clients such as browsers. A script can accept parameters, query or update the database, then display a customized page showing the results.

During development, PSPs can act like templates with a static part for page layout and a dynamic part for content. You can design the layouts using your favorite HTML authoring tools, leaving placeholders for the dynamic content. Then, you can write the PL/SQL scripts that generate the content. When finished, you simply load the resulting PSP files into the database as stored procedures.

Summary of PL/SQL Built-In Functions

PL/SQL provides many powerful functions to help you manipulate data. These built-in functions fall into the following categories:

Error reporting

2-38 Oracle Database PL/SQL User’s Guide and Reference

Summary of PL/SQL Built-In Functions

Number

Character

Datatype conversion

Date

Object reference

Miscellaneous

Table 2–4 shows the functions in each category. For descriptions of the error-reporting functions, see "SQLCODE Function" on page 13-117 and "SQLERRM Function" on page 13-118. For descriptions of the other functions, see Oracle Database SQL Reference.

Except for the error-reporting functions SQLCODE and SQLERRM, you can use all the functions in SQL statements. Also, except for the object-reference functions DEREF, REF, and VALUE and the miscellaneous functions DECODE, DUMP, and VSIZE, you can use all the functions in procedural statements.

Although the SQL aggregate functions (such as AVG and COUNT) and the SQL analytic functions (such as CORR and LAG) are not built into PL/SQL, you can use them in SQL statements (but not in procedural statements).

Fundamentals of the PL/SQL Language 2-39

Summary of PL/SQL Built-In Functions

Table 2–4 Built-In Functions

Error

Number

Character

Conversion

Date

Obj Ref

Misc

 

 

 

 

 

 

 

SQLCODE

ABS

ASCII

CHARTOROWID

ADD_MONTHS

DEREF

BFILENAME

SQLERRM

ACOS

ASCIISTR

CONVERT

CURRENT_DATE

REF

COALESCE

 

ASIN

CHR

HEXTORAW

CURRENT_TIME

TREAT

DECODE

 

ATAN

COMPOSE

RAWTOHEX

CURRENT_TIMESTAMP

VALUE

DUMP

 

ATAN2

CONCAT

RAWTONHEX

DBTIMEZONE

 

EMPTY_BLOB

 

BITAND

DECOMPOSE

ROWIDTOCHAR

EXTRACT

 

EMPTY_CLOB

 

CEIL

INITCAP

TO_BINARY_DOUBLE

FROM_TZ

 

GREATEST

 

COS

INSTR

TO_BLOB

LAST_DAY

 

LEAST

 

COSH

INSTR2

TO_BINARY_FLOAT

LOCALTIMESTAMP

 

NANVL

 

EXP

INSTR4

TO_CHAR

MONTHS_BETWEEN

 

NLS_CHARSET_DECL_LEN

 

FLOOR

INSTRB

TO_CLOB

NEW_TIME

 

NLS_CHARSET_ID

 

LN

INSTRC

TO_DATE

NEXT_DAY

 

NLS_CHARSET_NAME

 

LOG

LENGTH

TO_MULTI_BYTE

NUMTODSINTERVAL

 

NULLIF

 

MOD

LENGTH2

TO_NCHAR

NUMTOYMINTERVAL

 

NVL

 

POWER

LENGTH4

TO_NCLOB

ROUND

 

SYS_CONTEXT

 

REMAIN

LENGTHB

TO_NUMBER

SCN_TO_TIMESTAMP

 

SYS_GUID

 

DER

LENGTHC

TO_SINGLE_BYTE

SESSIONTIMEZONE

 

UID

 

 

 

 

ROUND

LOWER

 

SYS_EXTRACT_UTC

 

USER

 

 

 

 

 

SIGN

LPAD

 

SYSDATE

 

USERENV

 

 

 

 

 

SIN

LTRIM

 

SYSTIMESTAMP

 

VSIZE

 

 

 

 

 

SINH

NCHR

 

TIMESTAMP_TO_SCN

 

 

 

 

 

 

 

 

SQRT

NLS_INITCAP

 

TO_DSINTERVAL

 

 

 

 

 

 

 

 

TAN

NLS_LOWER

 

TO_TIME

 

 

 

 

 

 

 

 

TANH

NLSSORT

 

TO_TIME_TZ

 

 

 

 

 

 

 

 

TRUNC

NLS_UPPER

 

TO_TIMESTAMP

 

 

 

 

 

 

 

 

 

REGEXP_INSTR

 

TO_TIMESTAMP_TZ

 

 

 

 

REGEXP_LIKE

 

TO_YMINTERVAL

 

 

 

 

REGEXP_REPLACE

 

TRUNC

 

 

 

 

REGEXP_SUBSTR

 

TZ_OFFSET

 

 

 

 

REPLACE

 

 

 

 

 

 

RPAD

 

 

 

 

 

 

RTRIM

 

 

 

 

 

 

SOUNDEX

 

 

 

 

 

 

SUBSTR

 

 

 

 

 

 

SUBSTR2

 

 

 

 

 

 

SUBSTR4

 

 

 

 

 

 

SUBSTRB

 

 

 

 

 

 

SUBSTRC

 

 

 

 

 

 

TRANSLATE

 

 

 

 

 

 

TRIM

 

 

 

 

 

 

UNISTR

 

 

 

 

 

 

UPPER

 

 

 

 

 

 

 

 

 

 

 

2-40 Oracle Database PL/SQL User’s Guide and Reference

Соседние файлы в папке PL_SQL