9.1 PL/SQLThe Procedure Language extension to SQL (PL/SQL) is Oracle's proprietary programming language. It is used both server-side and client-side:
PL/SQL's strengths lie in its seamless integration with SQL and in its excellent server-side performance. Because Oracle's tools, Oracle Forms and Oracle Reports, also use PL/SQL as their programming language, these tools can leverage both seamless integration with the database and existing PL/SQL database programmer expertise for client-side development. 9.1.1 Using PL/SQLPL/SQL uses the same datatypes as SQL in the database; hence, no datatype conversions are necessary. PL/SQL effectively adds procedural language constructs, such as IF-THEN-ELSE logic, FOR loops , and so on, to SQL. Because PL/SQL stored procedures are executed in the database, this capability eliminates the data access delays caused by moving data across a network. This makes PL/SQL the superior choice for data- intensive manipulations in the database. Oracle Application Server provides a way to produce dynamic content via Oracle database stored procedures. The execution of stored procedures for web applications is facilitated through the Oracle HTTP Server module mod_plsql ; the Oracle HTTP Server was described in detail in Chapter 5. PL/SQL is a rich and powerful language that we only touch upon in this book. For much more detailed information, see Oracle PL/SQL Programming (O'Reilly). 9.1.2 PL/SQL Web ApplicationsOracle HTTP Server uses the mod_plsql module to route stored procedure requests to an Oracle database. mod_plsql provides a CGI environment for stored procedures. A request URI routed to mod_plsql from the Oracle HTTP Server is mapped to a corresponding stored procedure in the database as follows :
The logic of a stored procedure can use any of this information to formulate a response in the form of text that is then streamed back to the requester through mod_plsql to the Oracle HTTP Server, and so on. Two software development kits are available to aid the developer: the PL/SQL Web Toolkit and PL/SQL Server Pages. If you're familiar with Java, note that these can be compared to Java servlets and JSPs, respectively.
The difference between using the PL/SQL Web Toolkit and using PL/SQL Server Pages is that PL/SQL Web Toolkit procedures are PL/SQL programs with embedded HTML, while PL/SQL Server Pages are HTML files with embedded PL/SQL. The PL/SQL Web Toolkit is typically a more appropriate choice for programmers, whereas PSPs are a better fit for web designers. Ultimately, every PSP becomes a stored procedure. |