Wednesday, May 27, 2009

SQL Report Formatting Using HTML

See the magic. Following block of code will format the report in tabular format. The best way to generate SQL Report. Using it, you can view it in Browser. You can open it in Excel. 


SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus Report</title> -
<STYLE TYPE='TEXT/CSS'><!--BODY {background: ffffc6} --></STYLE>"
SET ECHO OFF
SPOOL employee.htm
SELECT FIRST_NAME, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000;
SPOOL OFF
SET MARKUP HTML OFF
SET ECHO ON

No comments: