Solved

SQL Navigator 4 Simple question.

Posted on 2004-08-19
8
2,391 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Accepted Solution

by:
pratikroy earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:Pierrick LOUBIER
Comment Utility
>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
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.

 
LVL 8

Assisted Solution

by:annamalai77
annamalai77 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank's all for bearing with me.


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

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.

Join & Write a Comment

Suggested Solutions

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…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

728 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

9 Experts available now in Live!

Get 1:1 Help Now