Oracle 8i | Oracle 9i | Oracle 10g | Oracle 11g | Oracle 12c | Miscellaneous | PL/SQL | SQL | Oracle RAC | Oracle Apps | Linux

SQL*Plus Web Reports

Both Oracle8i and Oracle9i allow the generation of HTML directly from SQL*Plus. This can be used to build complete reports, or output to be embedded in larger reports. The MARKUP HTML ON statement tell SQL*Plus to produce HTML output. The SPOOL ON option of this command indicates that the results should be encapsulated in <html><body>...</body></html> tags. If a complete HTML page is not required the SPOOL OFF option can be used.

The following example displays the contents of the SCOTT.EMP table as a HTML table.

SET ECHO OFF
SET MARKUP HTML ON SPOOL ON
SPOOL emp1.html
SELECT * FROM emp;
SPOOL OFF
SET MARKUP HTML OFF
SET ECHO ON

If this code is run from within an SQL*Plus session the resulting HTML file will look like this: emp1.html.

Alternatively, the script can saved as EmpHTMLReport.sql and run from the command line.

sqlplus scott/tiger@w2k1 @EmpHTMLReport.sql

The resulting HTML file will look like this: emp2.html.

Alternatively, an individual query can be saved to EmpSQL.sql and run with the appropriate command line parameters.

sqlplus -S -M "HTML ON" scott/tiger@w2k1 @EmpSQL.sql>emp3.html

The resulting HTML file will look like this: emp3.html.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.