在 Oracle SQL Developer SQL Worksheet 窗口中打印文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/193107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Print text in Oracle SQL Developer SQL Worksheet window
提问by thursdaysgeek
I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as
我正在使用 Oracle SQL(在 SQLDeveloper 中,使用 SQL 工作表)。我想在选择之前打印一个语句,例如
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.)
我用什么来打印/显示文本输出?这不是打印,因为这给了我错误:未声明绑定变量Table1
。DBMS_OUTPUT.PUT_LINE 是未知命令。(显然,我是一个没有经验的 SQLDeveloper 和 Oracle 用户。Print 肯定有一些同义词,但是我在不知道它是什么的情况下无法找到有关它的帮助。)
回答by Perry Tribolet
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
回答by H77
PROMPT text to print
Note:must use Run as Script (F5) not Run Statement (Ctl + Enter)
注意:必须使用 Run as Script (F5) 而不是 Run Statement (Ctl + Enter)
回答by Eddie Awad
回答by Leigh Riffel
You could put your text in a select statement such as...
您可以将文本放在选择语句中,例如...
SELECT 'Querying Table1' FROM dual;
回答by ΩmegaMan
回答by Michael Erickson
For me, I could only get it to work with
对我来说,我只能让它工作
set serveroutput on format word_wrapped;
The wraped and WRAPPED just threw errors: SQLPLUS command failed - not enough arguments
wraped 和 WRAPPED 只是抛出错误:SQLPLUS 命令失败 - 没有足够的参数
回答by Frank Staheli
If you don't want all of your SQL statements to be echoed, but you only want to see the easily identifiable results of your script, do it this way:
如果您不想回显所有 SQL 语句,而只想查看脚本的易于识别的结果,请按以下方式操作:
set echo on
REM MyFirstTable
set echo off
delete from MyFirstTable;
set echo on
REM MySecondTable
set echo off
delete from MySecondTable;
设置回声
REM MyFirstTable
关闭回声
从 MyFirstTable 中删除;
设置回声
REM MySecondTable
关闭回声
从 MySecondTable 中删除;
The output from the above example will look something like this:
上面示例的输出将如下所示:
-REM MyFirstTable
13 rows deleted.
-REM MySecondTable
27 rows deleted.
-REM MyFirstTable
删除了 13 行。
-REM MySecondTable
删除了 27 行。
回答by FrenkyB
If I ommit begin - end it is error. So for me this is working (nothing else needed):
如果我省略开始 - 结束它是错误的。所以对我来说这是有效的(不需要其他任何东西):
set serveroutput on;
begin
DBMS_OUTPUT.PUT_LINE('testing');
end;