HTML Markup in SQL*Plus    Feb 26

I was glad bump into the following SQL*Plus feature:-

 

Do you want to run SQL queries and get the output already in HTML Table Format?

If yes, keep reading

 

It is simple

just login to SQL*Plus

 

SQL>

and use the following command

 

SQL>SET MARKUP HTML ON

 

Then execute a query like

SQL> SELECT * FROM DEPT;

the output will be

<br>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
DEPTNO
</th>
<th scope="col">
DNAME
</th>
<th scope="col">
LOC
</th>
</tr>
<tr>
<td align="right">
10
</td>
<td>
ACCOUNTING
</td>
<td>
NEW YORK
</td>
</tr>
<tr>
<td align="right">
20
</td>
<td>
RESEARCH
</td>
<td>
DALLAS
</td>
</tr>
<tr>
<td align="right">
30
</td>
<td>
SALES
</td>
<td>
CHICAGO
</td>
</tr>
<tr>
<td align="right">
40
</td>
<td>
OPERATIONS
</td>
<td>
BOSTON
</td>
</tr>
</table>
<p>

BETTER YET

SPOOL   the output to a file

SQL>spool test.html

SQL> SELECT * FROM EMP

SQL>SPOOL OFF

THEN OPEN THE FILE IN YOUR BROWSER

AND THE BROWSER SHALL DISPLAY THE FOLLOWING

SQL> /
 

 

DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> SPOOL OFF