Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print text in Oracle SQL Developer SQL Worksheet window

I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as

PRINT 'Querying Table1'; SELECT * from Table1; 

What do I use to Print / show text output? It's not Print, because that gives me the error: Bind Variable Table1 is NOT DECLARED. DBMS_OUTPUT.PUT_LINE is an unknown command. (Obviously, I'm an inexperienced SQLDeveloper and Oracle user. There must be some synonym for Print, but I'm having trouble finding help on it without knowing what it is.)

like image 744
thursdaysgeek Avatar asked Oct 10 '08 21:10

thursdaysgeek


People also ask

How do I export text from SQL Developer?

Using the main menu, select Tools->Database Export. An Export wizard will open. At the top of the screen, enter a directory and file name.

Where will you view the SQL statement of a worksheet?

SQL History: Displays the SQL statements and scripts that you have executed. To re-enter a previously executed query in the worksheet, double-click the query in the history list. You can search for specific statements by clicking the Search icon.


2 Answers

enter image description here

for simple comments:

set serveroutput on format wrapped; begin     DBMS_OUTPUT.put_line('simple comment'); end; /  -- do something  begin     DBMS_OUTPUT.put_line('second simple comment'); end; / 

you should get:

anonymous block completed simple comment  anonymous block completed second simple comment 

if you want to print out the results of variables, here's another example:

set serveroutput on format wrapped; declare a_comment VARCHAR2(200) :='first comment'; begin     DBMS_OUTPUT.put_line(a_comment); end;  /  -- do something   declare a_comment VARCHAR2(200) :='comment'; begin     DBMS_OUTPUT.put_line(a_comment || 2); end; 

your output should be:

anonymous block completed first comment  anonymous block completed comment2 
like image 90
Perry Tribolet Avatar answered Sep 21 '22 08:09

Perry Tribolet


PROMPT text to print 

Note: must use Run as Script (F5) not Run Statement (Ctl + Enter)

like image 23
H77 Avatar answered Sep 22 '22 08:09

H77