sql*plus中关于procedure的问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:00:18
查询成绩单中的平均成绩,如果高于75分时,显示‘平均成绩大于75分’,否则显示‘平均成绩小于75分’。
表什么的都已经建好了,我写的是:
declare
avg_score report_card%rowtype;
s_score report_card.score%type;
begin
select avg(score) into s_score from report_card;
if s_score>=75 then dbms_output.put_line('平均成绩大于75分');
elsif s_score<75 then dbms_output.put_line('平均成绩小于75分');
end if;
end;
/
显示为:
PL/SQL 过程已成功完成。
可是没有输出结果,请教是怎么回事情啊?

先set serveroutput on;之后再执行。

使用:set serveroutput on
这个环境变量用于控制服务器输出,默认值为off,在默认情况下,当调整dbms_output等包时,不会在SQLPLUS上显示输出结果,为了显示,应该将此值设为on:如
set serveroutput on
exec dbms_output.put_line('hello');