Friday, March 13, 2009

How to display SQL code in text format exactly

In a blog post, we often need to display the program code, e.g. PL/SQL, SQL, and pure text output and trace file contents in text format exactly as it is, including space.

It had been bothering me for a long time. Finally, I found the solution, to use < pre > and < /pre > HTML tags.

Here is an example for RunStats output:
(Tested on http://www.blogger.com)

Without format:

..............................Fixed-Length...Delimited........Diff
STAT...CPU used by this sessio 179 202 23 ***
STAT...Elapsed Time 179 91 -88 ***
STAT...DB time 0 421 421 xxx
LATCH.process queue reference 1 58,878 58,877 ***
STAT...physical read bytes 212,992 0 -212,992
STAT...session uga memory max 604,728 115,320 -489,408
STAT...session pga memory max 720,896 131,072 -589,824

Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
7,629 64,444 56,815 11.84%


With < pre > and < /pre > tags to format text:

..............................Fixed-Length...Delimited........Diff
STAT...CPU used by this sessio 179 202 23 ***
STAT...Elapsed Time 179 91 -88 ***
STAT...DB time 0 421 421 xxx
LATCH.process queue reference 1 58,878 58,877 ***
STAT...physical read bytes 212,992 0 -212,992
STAT...session uga memory max 604,728 115,320 -489,408
STAT...session pga memory max 720,896 131,072 -589,824

Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
7,629 64,444 56,815 11.84%

I learned something new today, I'm so happy.

Reference


http://www.echoecho.com/htmltext04.htm

No comments: