dbms_output不输出结果,只提示过程已完成,在开始加一句SET SERVEROUTPUT ON这个就可以了,打开输出服务
2017-09-04
select a.deptno ,
sum(case when sal<3000 then 1 else 0 end) ,
sum(case when sal<=6000 and sal>=3000 then 1 else 0 end) ,
sum(case when sal>6000 then 1 else 0 end) ,
nvl(sum(sal),0)
from dept a, emp b
where a.deptno = b.deptno(+)
group by a.deptno
order by a.deptno;
sum(case when sal<3000 then 1 else 0 end) ,
sum(case when sal<=6000 and sal>=3000 then 1 else 0 end) ,
sum(case when sal>6000 then 1 else 0 end) ,
nvl(sum(sal),0)
from dept a, emp b
where a.deptno = b.deptno(+)
group by a.deptno
order by a.deptno;
2017-08-24
declare
cursor cur is select empno,sal from emp order by sal;
pempno emp.empno%type;
psal emp.sal%type;
cnt number :=0;
acc emp.sal%type;
cursor cur is select empno,sal from emp order by sal;
pempno emp.empno%type;
psal emp.sal%type;
cnt number :=0;
acc emp.sal%type;
2017-08-24
begin
select sum(sal) into acc from emp;
open cur;
loop
exit when acc>50000;
fetch cur into pempno,psal;
exit when cur%notfound;
select sum(sal) into acc from emp;
open cur;
loop
exit when acc>50000;
fetch cur into pempno,psal;
exit when cur%notfound;
2017-08-24
if acc+psal*0.1<=50000 then
update emp set sal = sal*1.1 where empno=pempno;
cnt := cnt+1;
acc := acc+psal*0.1;
end if;
end loop;
dbms_output.put_line(cnt ||' '||acc);
close cur;
end;
/
update emp set sal = sal*1.1 where empno=pempno;
cnt := cnt+1;
acc := acc+psal*0.1;
end if;
end loop;
dbms_output.put_line(cnt ||' '||acc);
close cur;
end;
/
2017-08-24
如果是在pl/sql developer中编译的话,只能在sql窗口中:
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('数字是0');
elsif pnum = 1 then
dbms_output.put_line('数字是1');
elsif pnum = 2 then
……
请忽略accept命令,不支持。set serveroutput on也不支持。
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('数字是0');
elsif pnum = 1 then
dbms_output.put_line('数字是1');
elsif pnum = 2 then
……
请忽略accept命令,不支持。set serveroutput on也不支持。
2017-08-17