Spool SQL query output to HTML format in SQLPLUS Oracle

Spool SQL query output to HTML format in SQLPLUS Oracle

Generate the simple SQL into HTML form

set pages 500
SET MARKUP HTML ON
spool report1.html
Select * from hr.departments where department_id < 20;
spool off

SAMPLE OUTPUT: REPORT1.HTML
Report1

Generate the html report with background color by using CSS from SQL Query
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>EMPLOYEE REPORT</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFC6} --> -
</STYLE>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"
spool C:\report2.html
Select * from hr.departments where department_id < 20;
spool off
Sample output : REPORT2.HTML

Report2

Generate html report by executing directly with SQLPLUS

--Execute directly with SQLPLUS
SQLPLUS -S -M "HTML ON TABLE 'BORDER="2"'" HR/your_password@Oracle_sid @C:\d\departments.sql > report3.html
--Save in file Departments.sql
Select * from hr.departments where department_id < 20;
EXIT

SAMPLE OUTPUT: REPORT3.HTML

1 thought on “Spool SQL query output to HTML format in SQLPLUS Oracle

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.