-
/* 1.得到有哪些系 select dno, dname from dep;-->光标-->循环-->退出条件:notfound; 2.得到系中,选修了“大学物理”课程学生的成绩 select grade from sc where cno = (select cno from course where cname = ??) and sno in (select sno from student where dno = ??) --> 带参数的光标-->循环-->退出条件:notfound 变量:1.初始值 2.如何得到 每个分数段的人数 count1 number; count2 number; count3 number; 每个系选修了“大学物理”学生的平均成绩 avggrade number; 1. 算术运算 2. select avg(grade) into avggrade from sc where cno = (select cno from course where cname = ??) and sno in (select sno from student where dno = ??); */查看全部
-
set serveroutput on declare cursor cemp is select empno,sal from testemp; pempno emp.empno%type; psal emp.sal%type; countEmp number:=0; salTotal number; begin select sum(sal) into salTotal from testemp; open cemp; loop --exit when salTotal > 50000; fetch cemp into pempno,psal; exit when cemp%notfound; salTotal:=salTotal + psal*0.1; IF(salTotal>50000) then salTotal:=salTotal - psal*0.1; exit; else update testemp set sal=sal*1.1 where empno=pempno; end if; countEmp:=countEmp+1; end loop; close cemp; dbms_output.put_line('人数:'||countEmp||' 薪水 '||salTotal); end; /查看全部
-
2.2查看全部
-
光标给员工工资赋值查看全部
-
for in1..10 loop end loop查看全部
-
loop exit when end loop查看全部
-
when loop loop查看全部
-
接受键盘数字输出查看全部
-
记录型变量查看全部
-
基本结构查看全部
-
基本结构查看全部
-
基本变量1查看全部
-
set on declar begin end查看全部
-
set serveroutput on declare cursor cdept is select deptno from dept; cursor cemp(dno number) is select sal from emp where deptno=dno; count1 number; count2 number; count3 number; totalsal number; pdeptno dept.deptno%type; psal emp.sal%type; begin open cdept; loop fetch cdept into pdeptno; exit when cdept%notfound; count1:=0; count2:=0; count3:=0; totalsal:=0; open cemp(pdeptno); loop fetch cemp into psal; exit when cemp%notfound; if psal<12000 then count1 :=count1+1; elsif psal<18000 then count2 :=count2+1; else count3 := count3+1; end if; totalsal:=totalsal+psal; end loop; insert into msg values(pdeptno,count1,count2,count3,nvl(totalsal,0)); close cemp; end loop; close cdept; dbms_output.put_line('统计完成'); commit; end; /查看全部
-
0不能做除数查看全部
举报
0/150
提交
取消