游标PLSQL/SQL引撑切换在什么情况下发生?
只听说过使用游标会发生切换 所以采用批量BULK 方法
下面4种情况使用游标的方法 哪种会发生切换 还是全部分会发生切换?
1
2
3
4
下面4种情况使用游标的方法 哪种会发生切换 还是全部分会发生切换?
1
Declare
Cursor myCur is select ename,job,sal,empno from emp;
varE myCur%rowType;
Begin
open myCur;
loop
fetch myCur into varE;
exit when myCur%notfound;
dbms_output.put_line(myCur%rowCount||' '||vare.empno||' '||vare.ename||' '||vare.sal);
end loop;
End
2
Declare
Cursor myCur is select * from emp;
varE myCur%rowType;
Begin
for varA in myCur
loop
select ename,job,sal,empno into varE from emp where empno= vara.empno;
dbms_output.put_line(vare.empno||' '||vare.ename||' '||vare.sal);
end loop;
End;
3
Declare
Cursor myCur is select ename,job,sal from emp;
type type_ename is table of emp.ename %type index by binary_integer;
type type_job is table of emp.job %type index by binary_integer;
type type_sal is table of emp.emp %type index by binary_integer;
l_ary_name type_ename;
l_ary_job type_job;
l_ary_sal type_sal;
Begin
open myCur;
loop
fetch myCur bulk collect into
l_ary_name,
l_ary_job,
l_ary_sal
limite 1;
exit when myCur%notfound;
dbms_output.put_line(myCur%rowCount||' '||l_ary_name(1)||' '||l_ary_job(1)||' '||l_ary_sal(1));
end loop;
End
4
Declare
Cursor myCur is select ename,job,sal from emp;
type type_ename is table of emp.ename %type index by binary_integer;
type type_job is table of emp.job %type index by binary_integer;
type type_sal is table of emp.emp %type index by binary_integer;
l_ary_name type_ename;
l_ary_job type_job;
l_ary_sal type_sal;
Begin
open myCur;
loop
fetch myCur bulk collect into
l_ary_name,
l_ary_job,
l_ary_sal
limite 1;
forall i in 1..l_ary_name.count
insert into table_b
(b.name,b.job,b.sal)
values(l_ary_name(i),l_ary_job(i),l_ary_sal(i))
exit when myCur%notfound;
end loop;
End
...全文
相关推荐
Oracle中PLSQL游标
PLSQL游标的概念:PLSQL游标是Oracle中的一种数据类型,用于存储查询结果集。游标可以分为两种:隐式游标和显式游标。隐式游标是系统自动创建的,而显式游标是用户手动创建的。9.
PLSQL游标编程培训内含实例
PLSQL(Procedural Language/Structured Query Language)是Oracle数据库为SQL添加的程序设计语言,它结合了SQL的查询功能和过程性编程语言的特点,使得开发者可以编写更复杂的数据库操作程序
PLSQL操作ORALCE数据库
声明部分用于定义变量、常量、游标和子程序;执行部分包含SQL语句和PLSQL语句,用于执行实际操作;异常处理部分则用于捕获和处理运行时错误。
plsql游标、集合简单使用
Oracle数据库中的PL/SQL编程是高级数据处理的关键部分,其中游标、集合和对象的使用是必不可少的技术。本文档着重介绍了PL/SQL中的两种主要类型的游标:隐式游标和显式游标,以及它们在处理SQL
PLSQL笔记-从hello word到触发器,包,游标高级应用
PLSQL,全称为Procedural Language/SQL,是Oracle数据库提供的结构化查询语言扩展,它结合了SQL(Structured Query Language)的查询功能和过程性编程语言的控制结构


