Chapter 6. Creating HTML Reports
Beginning with Oracle8i Database Release 2 (Version 8.1.6), you can use SQL*Plus to generate HTML pages. Instead of spooling a report to a printer, you can write it to an HTML file for viewing on your corporate intranet. With a bit of creativity and some cascading style sheet (CSS) skills, you can generate some good-looking web pages. In this chapter, I'll revisit some of the character-based reports from Chapter 5 and show some ways to render those same reports as HTML pages.
Tip
CSS is a mechanism for specifying the format of an HTML document. One reason CSS works well for SQL*Plus-generated HTML is because your CSS styles can reside in a file separate from the spool file generated by SQL*Plus, greatly reducing the likelihood that you will need to modify your SQL*Plus script to effect formatting changes. To learn more about CSS, read Eric Meyer's Cascading Style Sheets: The Definitive Guide (O'Reilly) and Eric Meyer on CSS (New Riders).
Getting the Data into an HTML Table
SQL*Plus doesn't offer much in the way of formatting HTML output, and what little capability SQL*Plus does offer in this area, you're better off avoiding in favor of CSS. When writing a report as HTML, SQL*Plus places all the detail rows, and their column headings, into an HTML table. One approach to generating an HTML page with such data is to capture only that table and concatenate it with other HTML that you write yourself to generate a complete web page.
When generating HTML from ...
Get Oracle SQL*Plus: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.