O'Reilly logo

Oracle SQL*Plus: The Definitive Guide, 2nd Edition by Jonathan Gennick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating the Entire Page

Having SQL*Plus generate the entire HTML page is possible. SQL*Plus generates a fairly decent-looking page by default, at least in Oracle Database 10g. The one problem you'll likely encounter is that the kinds of page headings you may be used to generating for plain-text reports do not always translate well into headings for HTML reports.

Using SQL*Plus's Default Formatting

To generate a report as a complete HTML page using SQL*Plus's default HTML formatting, add the command SET MARKUP HTML ON SPOOL ON near the beginning of any report script. Following is the beginning of Example 5-5 (in the file ex5-5.sql), with the SET MARKUP command added as the second line:

SET ECHO OFF
SET MARKUP HTML ON SPOOL ON

--Setup pagesize parameters
SET NEWPAGE 0
SET PAGESIZE 55

--Set the linesize, which must match the number of equal signs used
--for the ruling lines in the headers and footers.
SET LINESIZE 61

--Setup page headings and footings
TTITLE CENTER "The Fictional Company" SKIP 3 -
       LEFT "I.S. Department" -
       RIGHT "Project Hours and Dollars Report" SKIP 1 -
       LEFT "============================================================="
 . . .

The SPOOL ON option to SET MARKUP causes SQL*Plus to write <html>, <head>, and <body> tags before writing data from the query to the spool file, and to close those tags before closing the file. Thus, the result from running the script is a complete web page that you can load into a browser. SQL*Plus will write a series of CSS-style definitions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required