Solved

dbms output issue

Posted on 2012-03-14
5
357 Views
Last Modified: 2012-03-15
I want to include the date and the database name in this report but don't know much about formatting dbms_output

here is what I have - hash marks are not in the sql script

##############
set serverout on feed off pause off timing off pagesize 56 linesize 180 echo off

column today noprint new_value xdate
select to_char(sysdate,'MM-DD-YYYY')  today from dual;

col dbname new_value dbnm
select name dbname from v$database;


spool /home/sql/reports/&dbnm..reports.doc

begin
dbms_output.put_line('___________________________________________________________________________________');
dbms_output.put_line('                      Assessment Report');
dbms_output.put_line('___________________________________________________________________________________');
end;
/

prompt
prompt
prompt
#################

here is what I get


DBNAME
---------
DEVDATABASE
___________________________________________________________________________________
Assessment Report
___________________________________________________________________________________
0
Comment
Question by:bkreynolds48
  • 3
5 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 37721836
what do you want the output to look like?
you are printing the dbname, but you have defined your "today" column as noprint, so it's hidden
0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 37721932
as sdstuber said, you have to use your statement like this

column today print new_value xdate
select to_char(sysdate,'MM-DD-YYYY')  today from dual;


if you are using plsql, then its better to display everything in plsql itself,. why to go in sql prompt again and using spool for printing the output to file..??
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 37721959
if you want to do everything in pl/sql try something like this


set serverout on feed off pause off timing off pagesize 56 linesize 180 echo off
spool /home/sql/reports/&dbnm..reports.doc

begin
dbms_output.put_line('___________________________________________________________________________________');
dbms_output.put_line('                      Assessment Report');
dbms_output.put_line('Report date: ' || to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
dbms_output.put_line('DB Name: ' || sys_context('userenv','db_name'));
dbms_output.put_line('___________________________________________________________________________________');
end;
/

Open in new window

0
 
LVL 73

Expert Comment

by:sdstuber
ID: 37721969
>> as sdstuber said, you have to use your statement like this

actually, I would simply remove the noprint, because print is the default

or, as I did above, remove the sql and corresponding column commands completely.
0
 
LVL 1

Author Closing Comment

by:bkreynolds48
ID: 37724640
Thanks that worked
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

808 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