Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Navigator 4 Simple question.

Posted on 2004-08-19
8
Medium Priority
?
2,492 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 800 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 800 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 400 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 400 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 800 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

721 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