Solved

dbms output issue

Posted on 2012-03-14
5
363 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 74

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 74

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 74

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

820 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