declarecursor c1(v_dept_no number)
is select deptno,maxsal from test_s where deptno=v_dept_no;
begin
for c1_rec in c1(30)
loop
--dbms_output.put_line('c1:'||c1_rec.deptno||''||c1_rec.maxsal );
insert into test_s( deptno,maxsal)
select deptno,maxsal from test_s;
end loop;end;
有人能详细解释一下,上面写的是什么意思吗?
为什么`test_s表里有2条记录时,再执行时会跑出``多6条记录呢```不太明白这个思路``~!c1_rec 也是游标??
is select deptno,maxsal from test_s where deptno=v_dept_no;
begin
for c1_rec in c1(30)
loop
--dbms_output.put_line('c1:'||c1_rec.deptno||''||c1_rec.maxsal );
insert into test_s( deptno,maxsal)
select deptno,maxsal from test_s;
end loop;end;
有人能详细解释一下,上面写的是什么意思吗?
为什么`test_s表里有2条记录时,再执行时会跑出``多6条记录呢```不太明白这个思路``~!c1_rec 也是游标??
解决方案 »
- 询问有关oracle SQL developer工具的问题
- oracle 这样再怎么优化
- 一个itpub没人解决的问题
- 锁定报表不准添加和删除
- Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
- oemctl start oms time out!!怎么办
- 如何让我的Oracle 9i 数据库停下来
- 在自己的机子上创建了一个oracle数据库服务,不知道为什么每次用pl/sql developer连接上去要花一段时间
- open_cursors数量
- 很难处理的问题3天都没有解决完全没有思路
- ADO用msdaora.1 报:ORA-12154;换成ORAOLEDB.ORACLE.1正常。为什么?
- 新手写存储过程出错,向大家请教,谢谢,顶者有分
select deptno,maxsal from test_s;
这句话会是你的test_s记录数加倍
你开始是两条
循环一次后加倍变成4条
再循环一次再次加倍变成8条8-2=6
6条就这么出来的吧
用来loop 循环insert into test_s( deptno,maxsal)
select deptno,maxsal from test_s; 又是往同一个表中插入数据
循环后相当:2(原有)+2(第一次loop)+4(第二次loop)
共插入6条记录
把给定dept_no的部门的记录找出来,再插入到该表中,然后选出来,没有commmit也没有rollback,可能会造成锁的问题