Solved

dbms output issue

Posted on 2012-03-14
5
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

738 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