Formatting Sql output

Posted on 2006-04-20
Last Modified: 2012-06-21
I know this question is very vaque.
But I need to ask.

I need to format the sql output with some text in bold or a different color (??).
The problem is the third party control where i need to  print this
sql output does not support formatting.

Is there any way to do it ??
Question by:acpt
    LVL 142

    Accepted Solution

    >I need to format the sql output with some text in bold or a different color (??).
    coloring output requires rich text or html or the like.
    so unless you get some web page code that displays the data, applying colors etc, you won't find anything that colors your data.
    LVL 22

    Expert Comment

    by:Ivo Stoykov
    Hello acpt,

    > third party control ?

    what application are trying to use about printing? Client, Web based?


    LVL 4

    Assisted Solution


    SQL Plus is offering to turn on HTML Markup tags while spooling to a file. You can use this option to generate an HTML file.. If you want to give color to particular places then you need to incorporate html tags in ur sql script.... I am pasting small code for example in this window..Hope this will help you...

    Set markup html on spool on preformat off entmap off -
    HEAD "<TITLE>Health Check  Report</TITLE> -
    <STYLE type='text/css'> - <!-- BODY {background: #FFFFFF} --> - </STYLE>" -
    BODY "TEXT='#0066CC'" -
    TABLE "class=detail cellspacing=0 WIDTH='98%' BORDER='1'"
    set echo off
    spool c:\healthcheck.html
    REM Database Health monitoring script.
    REM Segments Max extents & Current extent comparison
    set line 180
    set pagesize 10000
    set feedback off
    set heading off
    select '<H3> Health Check for '|| Name || ' as on '|| to_char(sysdate,'DD-MON-YYYY:HH24:MI:SS')||'</h3>' Time from dual,v$database;
    PROMPT <h4> Objects Reaching Max extents </h4>
    set heading on
    col segment_name format a40 heading "Object Name"
    col max_extents format 9999999999 heading "Max Extents"
    col curr_extents format 99999999999 heading "Curent Extents"
    prompt <font  color="#ff0000">
    select a.segment_name,a.max_extents,b.curr_extents from dba_segments a,(select
    segment_name,max(extent_id) curr_extents from dba_extents group by segment_name) b where a.segment_name = b.segment_name
    and (a.max_extents - b.curr_extents) <= 10;
    prompt </FONT>
    set heading off
    Spool Off

    LVL 19

    Expert Comment

    >>BODY "TEXT='#0066CC'"

         not supportd in oracle 9i. Are you using oracle 10?
    LVL 19

    Assisted Solution

    >> some text in bold or a different color

          your question is a little vague. what do you mean by this?

          HTML might be way to do from sql*plus. But it might require other steps to do it:

         you need to do is to turn HTML mode on and insert css style into sql:

    -- use HTML mode
    set markup HTML on  
    spool test.html
    select col1 from <your table>
    spool off
    set markup HTML off
    LVL 47

    Assisted Solution

    Oracle Reports is what you need!
    Oracle Reports can produce output in every 'known' format: .pdf, .xls, .xml, .txt, .html
    with needed colors, fonts, headers, footers, etc. and even is able to email the produced files.

    Disadvantage: needs installation of Oracle developer Suite and Forms/reports server
    But if you will produce many reports definetelly you need Reports generator (there are also other; Crystal Reports,...).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Article by: Swadhin
    From the Oracle SQL Reference ( we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now