DBMS_OUTPUT.PUT_LINE 不打印 [英] DBMS_OUTPUT.PUT_LINE not printing
问题描述
当执行下面的代码时,它只是说程序已经完成,并没有打印我想要的信息(名字,姓氏),然后是下表中选择查询的其他值.
When executing the following code, it just says the procedure is completed and doesn't print the infomation i want it to (firstName, lastName) and then the other values from the select query in a table below.
CREATE OR REPLACE PROCEDURE PRINT_ACTOR_QUOTES (id_actor char)
AS
CURSOR quote_recs IS
SELECT a.firstName,a.lastName, m.title, m.year, r.roleName ,q.quotechar from quote q, role r,
rolequote rq, actor a, movie m
where
rq.quoteID = q.quoteID
AND
rq.roleID = r.roleID
AND
r.actorID = a.actorID
AND
r.movieID = m.movieID
AND
a.actorID = id_actor;
BEGIN
FOR row IN quote_recs LOOP
DBMS_OUTPUT.PUT_LINE('a.firstName' || 'a.lastName');
end loop;
END PRINT_ACTOR_QUOTES;
/
当设置服务器输出时,我得到
When setting server output on, I get
a.firstNamea.lastName
a.firstNamea.lastName
a.firstNamea.lastName
a.firstNamea.lastName
多次!
推荐答案
它只是说程序完成了"这句话中的它"是什么?
What is "it" in the statement "it just says the procedure is completed"?
默认情况下,大多数工具不会为 dbms_output
配置缓冲区来写入,也不会在代码执行后尝试从该缓冲区读取.另一方面,大多数工具都具有这样做的能力.在 SQL*Plus 中,您需要使用命令 set serveroutput on [size N|unlimited]
.所以你会做类似的事情
By default, most tools do not configure a buffer for dbms_output
to write to and do not attempt to read from that buffer after code executes. Most tools, on the other hand, have the ability to do so. In SQL*Plus, you'd need to use the command set serveroutput on [size N|unlimited]
. So you'd do something like
SQL> set serveroutput on size 30000;
SQL> exec print_actor_quotes( <<some value>> );
在 SQL Developer 中,您将转到 View |DBMS 输出
以启用 DBMS 输出窗口,然后按下绿色加号图标以启用特定会话的 DBMS 输出.
In SQL Developer, you'd go to View | DBMS Output
to enable the DBMS Output window, then push the green plus icon to enable DBMS Output for a particular session.
此外,假设您不想为每一行打印文字a.firstNamea.lastName",您可能想要
Additionally, assuming that you don't want to print the literal "a.firstNamea.lastName" for every row, you probably want
FOR row IN quote_recs
LOOP
DBMS_OUTPUT.PUT_LINE( row.firstName || ' ' || row.lastName );
END LOOP;
这篇关于DBMS_OUTPUT.PUT_LINE 不打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!