-
if语句情况三查看全部
-
if语句情况二查看全部
-
if语句情况一查看全部
-
PL/SQL查看全部
-
set serveroutput on:打开打印查看全部
-
fetch的作用查看全部
-
光标的用法查看全部
-
promot 提示查看全部
-
set SERVEROUTPUT ON DECLARE CURSOR cdept is SELECT deptno from dept; pdeptno dept.deptno%type; CURSOR cemp(dno number) is select sal from emp where deptno=dno; psal emp.sal%type; count1 number; count2 number; count3 number; saltotal number; begin open cdept; loop fetch cdept into pdeptno; exit when cdept%notfound; count1:=0; count2:=0; count3:=0; select sum(sal) into saltotal from emp where deptno=pdeptno; open cemp(pdeptno); loop fetch cemp into psal; exit when cemp%notfound; if psal <3000 then count1:=count1+1; elsif psal >=3000 and psal < 6000 then count2:=count2+1; else count3:=count3+1; end if; end loop; close cemp; INSERT into msg values(pdeptno,count1,count2,count3,nvl(saltotal,0)); end loop; close cdept; commit; DBMS_OUTPUT.PUT_LINE('统计完成'); end;查看全部
-
declare cursor cemp is select empno,sal from emp order by sal; pempno emp.empno%type; psal emp.sal%type; countemp number :=0; saltotal number; begin select sum(sal) into saltotal from emp; open cemp; loop fetch cemp into pempno,psal; exit when saltotal+psal*0.1 > 240000; exit when cemp%notfound ; update emp set sal=sal*1.1 where pempno=empno; countemp := countemp+1; saltotal :=saltotal+ psal*0.1; end loop; close cemp; commit; dbms_output.put_line('人数是'||countemp||'涨后工资总额:'||saltotal); end;查看全部
-
declare cursor cemp is select to_char(t.hiredate, 'yyyy') as 入职年份 from emp t; phiredate varchar2(4); count80 number := 0; count81 number := 0; count82 number := 0; begin open cemp; loop fetch cemp into phiredate ; exit when cemp %notfound; if phiredate ='1980' then count80 := count80 + 1; elsif phiredate = '1981' then count81 := count81 + 1; else count82 := count82 + 1; end if; end loop; CLOSE cemp; dbms_output.put_line('total:' || (count80 + count81 + count82)); dbms_output.put_line('1980:' || count80); dbms_output.put_line('1981:' || count81); dbms_output.put_line('1982:' || count82); end;查看全部
-
IF语句,ELSEIF写法查看全部
-
记录型变量例子,||是字符串连接符。查看全部
-
记录型变量,返回一行查看全部
-
引用形变量例子。注意select into的这个另一种赋值,顺序需一致查看全部
举报
0/150
提交
取消