Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

console out feature 1

Status
Not open for further replies.

palovidiu

Programmer
Nov 30, 2005
14
0
0
RO
using "SQLPlus Worksheet", sql query console provided by
Oracle .. or "sql plus" , and not some fancy shmancy TOAD or SQL navigator I would like to do this :

--run this pl/sql block
declare
someText VARCHAR(100);
begin
someText:='some trivial message for the masses';
select someText as Message from dual;
end;


--and get something like
Message
-------

some trivial message for the masses


the example doesn't work, it sugest to use INTO clause
in the select ..

I would like then in conclusion , to be able to return
non-numeric output from inside a pl/sql block ..

anyone has some ideea ?

thank you
 
It's objecting to this line:

select someText as Message from dual;

You need to select INTO a variable.
 
Palo,

Building upon Sem's (Dima's) correct suggestion (since the method can be somewhat problematic for the uninitiated user), here is a code segment that illustrates the concept (from a SQL> prompt):
Code:
set serveroutput on
declare 
  someText VARCHAR(100);
begin
  someText:='some trivial message for the masses';
  dbms_output.put_line(someText);
end;
/
some trivial message for the masses
Let us know if this is useful.

P.S. Sem/Dima, did you receive my e-mail message several days ago? Please let me know, either way.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Another option is (a code for sql*plus):

Code:
var rc refcursor

declare
  someText VARCHAR(100);
begin
  someText:='some trivial message for the masses';
  open :rc for select someText as Message from dual;
end;
/
print rc

Regards, Dima
 
Dima,

I had know idea you could declare variables and print cursors outside of a pl/sql block. That's good to know.

- Dan
 
thanks,

yes it is dbms_output.put_line, i found out for my self
on the same day I posted the message.

thank you for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top