函数能不能用dbms_output.put_line()输出?
小鸟向前飞 2010-08-02 07:24:44 --创建一个表
create table salary_details
(
empcode varchar2(10) not null,
workdays number,
salary number,
constraints salary_details_empcode_pk primary key(empcode)
);
这是我写的函数
--利用在问题1种创建的salary_details表,创建work_days函数,
--接受EMPCODE雇员编号,并检查所有雇员的工作天数。
--标准工作天数为22天,雇员每少工作一天从其工资中扣除50元。
--函数输出雇员最后的工资,工作天数多于标准天数不加工资,
--工资扣完为止,不可为负值。
create or replace function xn_calday1(code varchar2)
return number is v_sal number;
v_days number;
begin
select workdays into v_days from salary_details where empcode=code;
if v_days>=22 then
select salary into v_sal from salary_details where empcode=code;
--dbms_output.put_line(code||'工作了'||v_days||'天,工资是:'||v_sal);
elsif v_days<22 then
select salary into v_sal from salary_details where empcode=code;
v_sal:=v_sal-(22-v_days)*50;
if v_sal<=0 then
v_sal:=0;
--dbms_output.put_line(code||'工作了'||v_days||'天,工资是:'||'0');
end if;
--dbms_output.put_line(code||'工作了'||v_days||'天,工资是:'||v_sal);
end if;
dbms_output.put_line(code||'工作了'||v_days||'天,工资是:'||v_sal);
return v_sal;
end;
为什么最后没有在窗口中打印出“code||'工作了'||v_days||'天,工资是:'||v_sal”?