-
推荐使用Loop循环,其在使用光标的时候比较方便查看全部
-
select ename,sale into pename,psal from emp where empno = 7839;查看全部
-
begin pppcname varchar2 := '大学物理'; open cdept; loop fetch cdept into pdno,pdname; exit when cdept%notfound; count1:=0;count2:=0;count3:=0;avggrade:=0;Rcount:=0;zgrade:=0; open csc(pppcname,pdno); loop fetch csc into pgrade; exit when scs%notfound; if pgrade < 60 then count1:=count1+1; elsif pgrade > 60 and pgrade < 85 then count2:=count2+1; elsif pgrade >85 then count3:=count3+1; end if ; zgrade:=zgrade+pgrade; end loop; Rcount:= count1+count2+count3; avggrade:=zgrade/Rcount; insert into test values(pppcnamea,pdname,count1,count2,count3,avggrade); close csc; end loop; close cdept; dbms_output.put_line('完成'); commit; end;查看全部
-
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; totalsal number; 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 < 3000 then count1:=count1+1; elsif psal >= 3000 and psal <= 6000 then count2:=count2+1; elsif psal > 6000 then count3:=count3+1; end if; totalsal:=totalsal+psal; end loop; insert into test values(pdeptno,count1,count2,count3,totalsal); close cemp; end loop; close cdept; dbms_output.put_line('完成'); commit; end;查看全部
-
set serveroutput on; declare cursor cemp is select empno,sal from emp order by sal; pempno emp.empno%type; psal emp.sal%type; count1 number:=0; totalsal number; begin select sum(sal) into totalsal from emp; open cemp; loop exit when totalsal>50000; fetch cemp into pempno,psal; exit when cemp%notfound; totalsal:=totalsal+psal*0.1; if totalsal>50000 then totalsal:=totalsal-psal*0.1; else update emp set sal=sal*1.1 where empno=pempno; count1:=count1+1; end if ; end loop; dbms_output.put_line('count1人数='||count1||' totalsal总额='||totalsal); close cemp; commit; end;查看全部
-
dbms_output.put_line部分输出total时一定要带括号查看全部
-
1、fetch cemp into pcemp; 2、exit when cemp%notfound; cemp为指针,当执行完语句1时,cemp指向一下字段。假设后面没有字段了,语句2,应该对出才对呀?为什么没有退出??查看全部
-
瀑布模型查看全部
-
ssss查看全部
-
timeout_on_resource查看全部
-
2.2引用型和记录型变量 my_name emp.ename%type; declare pname emp.ename%type; psal emp.sal%type; begin select ename,sal into pname.psal from emp where empno=7839; dbms_output.put_line(pname||"的薪水是"||psal); end; / emp_rec emp%rowtype; 取表中一行的类型 理解成数组。 emp_rec.ename :="ADAMS"; declare emp_rec emp%rowtype; begin select * into emp_rec where empno=7839; dbms_output.put_line(emp_rec.enmae||"的薪水是"||emp_rec.sal); end; /查看全部
-
declare pnumber number(7,2); pname varchar2(20); pdate date; begin pnumber :=1; dbms_output.put_line(pnumber); pname :="Tom"; pdate :=sysdate; end; /查看全部
-
PL/SQL(Procedure Language/SQL)是Oracle对sql语言的过程化扩展 在SQL中增加了过程处理语句,比如分支,循环 使SQL语言具有过程处理能力。 把SQL语言的数据操纵能力和过程语言的数据处理能力结合起来 简单高效 灵活实用查看全部
-
1.2PL/SQL的作用 ResultSet rs="select empno,job from emp"; while(rs.next()){ int eno=rs.getInt("empno"); String job=rs.getString("job"); if("PRESIDENT".equals(job)){ update emp set sal=sal+1000 where empno=eno; }else if("MANAGER".equals(job)){ update emp set sal=sal+800 where empno=eno; }else { update emp set sal=sal+400 where empno=eno; } } PLSQL作用:操作数据库的效率更高,便于存储; declare --说明部分 begin --程序体 dbms_output.put_line("Hello World"); end; / --打开输出开关 set serveroutput on / --查看程序包的结构 desc dbms_output查看全部
-
oracle sql developer linux的安装.sh的文件 用户名、口令:scott/tiger 如果以sys登录,角色要选成SYSDBA 主机名是服务器的IP地址,端口是1521; SID是数据库名字,orcl //打开行号:工具-首选项-代码编辑器-行装订线-显示行数 //连接mysql:工具-首选项-第三方JDBC驱动程序-添加条目-mysql...-bin.jar查看全部
举报
0/150
提交
取消