DBMS_OUTPUT.PUT_LINE无法打印 [英] DBMS_OUTPUT.PUT_LINE not printing

查看:214
本文介绍了DBMS_OUTPUT.PUT_LINE无法打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行以下代码时,它只是说该过程已完成,并且没有将我希望它的信息打印到(firstName,lastName),然后是下表中来自选择查询的其他值.

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 Output以启用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屋!

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