我在Server和Oracle上都编码。
当我在Server中编码时,我使用了以下内容:
OPEN curUSERS;
CLOSE curUSERS;
DEALLOCATE curUSERS;现在,当我在Oracle中编码时,我使用了以下内容:
OPEN curUSERS;
CLOSE curUSERS;我在PL/SQL中看到了一个DEALLOCATE关键字,但是当我使用这个语句时
DEALLOCATE(curUSERS);它抛出一个错误。我如何在PL/SQL中做同样的事情(去分配)?
发布于 2014-10-24 23:34:38
Oracle不需要显式地释放游标的内存。只要CLOSE(cursor)就行了。
发布于 2014-10-25 03:54:57
应尽可能避免显式游标。显式游标需要更多代码,而且速度较慢,因为它们不会自动批量收集。用于循环的游标简单且快速。
样例模式
drop table table1;
create table table1 as select 1 a from dual;显式游标-更多代码,性能较差的
declare
v_a number;
cursor table1_cursor is select a from table1;
begin
open table1_cursor;
loop
fetch table1_cursor into v_a;
exit when table1_cursor%notfound;
dbms_output.put_line(v_a);
end loop;
close table1_cursor;
end;
/用于无循环代码的游标,性能更好的
begin
for table1_rows in (select a from table1)
loop
dbms_output.put_line(table1_rows.a);
end loop;
end;
/https://stackoverflow.com/questions/26557564
复制相似问题