-
引用型变量 my_name emp.ename%type;查看全部
-
PL/SQL的程序结构查看全部
-
存储过程格式 declare --说明部分(变量、光标或者例外) begin --程序体 dbms_output.put_line("Hello World"); end; /查看全部
-
PL/SQL是面向过程的语言。查看全部
-
(1)光标就是一个结果集(Result Set) (2)光标的语法: cursor 光标名[(参数名 数据类型[,参数名 数据类型]...)] IS SELECT 语句; cursor c1 is select ename from emp; 打开光标 open c1; 取一行光标的值: fetch c1 into pename;(取一行到变量) 关闭光标并释放资源 close c1;查看全部
-
修改光标的限制: SQL> alter system set open_cursors=400 scope=both;查看全部
-
不同数据库的SQL扩展查看全部
-
plsql是一种过程语言查看全部
-
程序结构查看全部
-
oracle的安装查看全部
-
pl/sql查看全部
-
光标 带参数查看全部
-
plsql 程序查看全部
-
select deptno from dept; pdeptno number; select sal from emp where deptno=? count1 number; count2 number; count3 number; saltotal number; set serveroutput on; declare cursor cdeptno is select deptno from dept; pdeptno dept.deptno%type; cursor csal(dno number) is select sal from emp where deptno=dno; psal emp.sal%type; count1 number; count2 number; count3 number; saltotal number; begin open cdeptno; loop fetch cdeptno into pdeptno; exit when cdeptno%notfound; open csal(pdeptno); count1:=0; count2:=0; count3:=0; saltotal:=0; loop fetch csal into psal; exit when csal%notfound; if psal >6000 then count3:=count3+1; elsif psal>=3000 and psal<6000 then count2:=count2+1; else count1:=count1+1; end if; saltotal:=saltotal+sal; end loop; close csal; insert into saltab values(pdeptno,count1,count2,count3,saltotal); end loop; close cdeptno; commit; dbms_output.put_line('完成!'); end; /查看全部
-
/* select empno,sal from emp order by sal; 需要定义游标, 并为光标定义两个变量 pempno,psal 定义一个计数器,保存为多少员工涨工资; 定义两个变量,分别用于存储涨钱前和涨钱后的工资总额; 开启光标>开启循环>取值>退出条件>结束循环>关闭光标 */ set serveroutput on; declare cursor cemp is select empno,sal from emp order by sal; pempno emp.empno%type; psal emp.sal%type; pcount number:=0; psum number; begin select sum(sal) into psum from emp; open cemp; loop fetch cemp into pempno,psal; exit when cemp%notfound or psum>250000 or psum+psal*0.1>250000; update emp set sal=psal*1.1 where empno=pempno; psum:=psum+psal*0.1; pcount:=pcount+1; end loop; close cemp; commit; dbms_output.put_line('涨后的工资总额为'psum); dbms_output.put_line('涨工资的总人数为'pcount); end; /查看全部
举报
0/150
提交
取消