Solved

SQL Navigator 4 Simple question.

Posted on 2004-08-19
8
2,472 Views
Last Modified: 2008-01-09

Here it is:


I try to show a simple string in the output window. so i use this:

dbms_output.put_line('Hello World');


when I run I get an error.


Please help me to find out what to do about this.

or if this not the correct way then how can I show 'hello world" in the output window???





0
Comment
Question by:unknown_routine
[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
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Accepted Solution

by:
pratikroy earned 200 total points
ID: 11843972
I believe you are writing this in SQL Editor Window. You are supposed to be writing the SQL or PL/SQL statements there.

Try to have DBMS_OUTPUT statement within a BEGIN ... END block, like :

BEGIN
dbms_output.put_line('Hello World');
END;
/

0
 
LVL 9

Assisted Solution

by:pratikroy
pratikroy earned 200 total points
ID: 11843996
And, to ensure that you see the output, you will have to click on 'Server Output' which is one of the options in Session (in the top level menu).

Hope this helps !
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 11844122
Thanks for the comments.

Please explain:

<<I believe you are writing this in SQL Editor Window.>>

Where else could I wirte the code?

<<You are supposed to be writing the SQL or PL/SQL statements there.>>


isn't  
 dbms_output.put_line('Hello World');
is any pl/sql code?

<<you will have to click on 'Server Output' >>
Can you explain Server output? what happen if you set it to on and off?


0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 8

Expert Comment

by:Pierrick LOUBIER
ID: 11848166
>Can you explain Server output? what happen if you set it to on and off?
Check http://www.experts-exchange.com/Databases/Oracle/Q_21061102.html
0
 
LVL 8

Assisted Solution

by:annamalai77
annamalai77 earned 100 total points
ID: 11849313
my dear friend

run this from a sql file

sql> ed sample.sql

set serveroutput on
declare
a number := 10;
b varchar2(25) := 'This is a test file';
begin
  dbms_output.put_line('The Number is : ' || to_char(a);
  dbms_output.put_line(b);
end;

save close the file and then run it from sql prompt.

regards
annamalai
0
 
LVL 8

Assisted Solution

by:annamalai77
annamalai77 earned 100 total points
ID: 11849318
sorry friend

missed a ')' in the dbms_output.

corrected one is here

my dear friend

run this from a sql file

sql> ed sample.sql

set serveroutput on
declare
a number := 10;
b varchar2(25) := 'This is a test file';
begin
  dbms_output.put_line('The Number is : ' || to_char(a));
  dbms_output.put_line(b);
end;

save close the file and then run it from sql prompt.

regards
annamalai

0
 
LVL 9

Assisted Solution

by:pratikroy
pratikroy earned 200 total points
ID: 11850681
Dont worry about that comment. You have written in the SQL editor which is correct. I just wanted to tell you that a PL/SQL statement should be written as a PL/SQL statement, within BEGIN .. END statement. Alternatively you could write
EXEC dbms_output.put_line('Hello World');

dbms_output is a package, and has to be executed either within BEGIN ... END statements or, by executing the package with EXEC statement. Hope it is clear now.

<<Can you explain Server output? what happen if you set it to on and off?>>

DBMS_OUTPUT package actually writes to to the SERVER OUTPUT buffer. If the setting is off, you will not be able to see the 'Hello World' in your Output window.

If you have any more questions, please feel free to ask !
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 11851471
Thank's all for bearing with me.


I'm increasing point to 300 and split the points.

0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

617 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