在Oracle SQL Developer SQL工作表窗口中打印文本 [英] Print text in Oracle SQL Developer SQL Worksheet window

查看:123
本文介绍了在Oracle SQL Developer SQL工作表窗口中打印文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle SQL(在SQLDeveloper中,使用SQL Worksheet).我想在选择之前打印一条语句,例如

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;

我要使用什么来打印/显示文本输出?它不是Print,因为这给了我错误:Bind Variable Table1未声明. DBMS_OUTPUT.PUT_LINE是未知命令. (显然,我是一个没有经验的SQLDeveloper和Oracle用户.必须有一些Print的同义词,但是在不知道它是什么的情况下,我很难找到帮助.)

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.)

推荐答案

简单评论:

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

-- do something

begin
    DBMS_OUTPUT.put_line('second simple comment');
end;
/

您应该得到:

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;

您的输出应为:

anonymous block completed
first comment

anonymous block completed
comment2

这篇关于在Oracle SQL Developer SQL工作表窗口中打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆