Skip to Content
Oracle SQL*Plus Pocket Reference, 3rd Edition
book

Oracle SQL*Plus Pocket Reference, 3rd Edition

by Jonathan Gennick
November 2004
Intermediate to advanced
152 pages
2h 50m
English
O'Reilly Media, Inc.
Content preview from Oracle SQL*Plus Pocket Reference, 3rd Edition

Formatting 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 example, for viewing on your corporate intranet.

The Concatenation Approach

One approach to generating an HTML page with such data is to capture only the table containing the data, and to concatenate it with other HTML that you write yourself in order to generate a complete web page. The following script, for example, will generate a file named middle.html having an HTML table of employee data:

SET PAGESIZE 6
SET MARKUP HTML ON TABLE ""
COLUMN employee_id HEADING "ID"
COLUMN employee_name HEADING "Employee Name"
COLUMN employee_hire_date HEADING "Hire Date"
COLUMN employee_billing_rate –
       HEADING "Rate" FORMAT "$999.99"
SET TERMOUT OFF
SET FEEDBACK OFF
SPOOL middle.html
SELECT employee_id, employee_name,
       employee_hire_date,
       employee_billing_rate
FROM employee;
SPOOL OFF

Be sure to execute these commands from a script! If you type them interactively, SQL*Plus will also write the SELECT statement to the spool file. Assuming that you execute from a script file (using @ or START), the resulting middle.html file will contain a single, HTML table with all the query output:

<p> <table> <tr> <th scope="col"> ID </th> <th scope="col"> Employee Name </th> <th scope="col"> Hire Date </th> <th scope="col"> Rate </th> </tr> <tr> <td align="right"> 101 </td> <td> Marusia Churai </td> <td> 15-NOV-61 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle SQL*Plus Pocket Reference

Oracle SQL*Plus Pocket Reference

Jonathan Gennick

Publisher Resources

ISBN: 9781491926680Errata Page