ORA-01002: fetch out of sequence
Cause: In a host language program, a FETCH call was issued out of sequence. A successful parse-and-execute call must be issued before a fetch. This can occur if an attempt was made to FETCH from an active set after all records have been fetched. This may be caused by fetching from a SELECT FOR UPDATE cursor after a commit. A PL/SQL cursor loop implicitly does fetches and may also cause this error.
Action: Parse and execute a SQL statement before attempting to fetch the data.
实际应用及解决方法:
1、在你取完部分数据并执行的过程中,可能有commit或者rollback语句,导致在表t上加的lock被释放掉,再取数据的时候导致出错。
Fetching Across Commits
The FOR UPDATE clause acquires exclusive row locks. All rows are locked when you
open the cursor, and they are unlocked when you commit your transaction. So, you
cannot fetch from a FOR UPDATE cursor after a commit. If you do, PL/SQL raises an
exception. In the following example, the cursor FOR loop fails after the tenth insert:
DECLARE
CURSOR c1 IS SELECT ename FROM emp FOR UPDATE OF sal;
ctr NUMBER := 0;
BEGIN
FOR emp_rec IN c1 LOOP -- FETCHes implicitly
...
ctr := ctr + 1;
INSERT INTO temp VALUES (ctr, ’still going’);
IF ctr >= 10 THEN
COMMIT; -- releases locks
END IF;
END LOOP;
END;
If you want to fetch across commits, do not use the FOR UPDATE and CURRENT OF
clauses. Instead, use the ROWID pseudocolumn to mimic the CURRENT OF clause.
Simply select the rowid of each row into a UROWID variable. Then, use the rowid to
identify the current row during subsequent updates and deletes. An example
follows:
DECLARE
CURSOR c1 IS SELECT ename, job, rowid FROM emp;
my_ename emp.ename%TYPE;
my_job emp.job%TYPE;
my_rowid UROWID;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO my_ename, my_job, my_rowid;
EXIT WHEN c1%NOTFOUND;
UPDATE emp SET sal = sal * 1.05 WHERE rowid = my_rowid;
-- this mimics WHERE CURRENT OF c1
COMMIT;
END LOOP;
CLOSE c1;
END;
2、禁用自动提交试试。如果你仍然有其他的行在查询的时候也禁用手工提交,当有for update游标仍然打开时执行的任何提交可能会造成这个错误。
setAutoCommit(false)
分享到:
相关推荐
‘your user_dump_dest‘, ‘read‘) create a wrapper package for utl_file pk_utl_file.sql As TFMADMIN set up the tables, views and sequence tfmadmin_objects.sql create the controlling package pack_...
fetch请求超时,在fetch的基础上做的可以设置超时时间的 javascript 插件,具体使用请查看我的博客 https://blog.csdn.net/yumikobu/article/details/80167982
主要介绍了javascript实现fetch请求返回的统一拦截,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Fetch Robot
本文通过实例代码给大家介绍了JavaScript 用fetch 实现异步下载文件功能,非常不错,具有参考借鉴价值,需要的朋友可以参考下
西门子 TCP通信中的Fetch和Write用法,PLC侧无需编程,公开的通信格式
Autonomy提供的OracleFetch用户手册
Fetch is a simple, powerful, customizable file download manager library for Android. Features Simple and easy to use API. Continuous downloading in the background. Concurrent downloading support. ...
iOS 7学习:多任务处理之Background Fetch对应的Demo,已经修正不断Background Fetch中出现的多线程锁问题。
Fetch error error fetch fetch
electron-main-fetch:在Electron的主要进程中使用浏览器Fetch API
前端项目-fetch,fetch是window.fetch的javascript polyfill。全局fetch函数是web请求和处理响应的简单方式,不使用xmlhttprequest。这个polyfill编写的接近标准的fetch规范。
import { timeout } from 'fetch-friends' ; // fetch aborts when API takes longer than 5 seconds to respond export default timeout ( 5000 , fetch ) ; fetch从不在源代码中所提到的,所以fetch-friends可以...
Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据
react native 使用 fetch 进行网络请求,fetch 的封装以及调用实例 (fetch demo) 1》下载该文件 2》使用命令行工具输入命令:react-native init ZXJNetDemo 3》将下载的文件中的.js 文件 放到刚生成项目的...
正确理解hibernate fetch 的作用
Laravel开发-fetch 把你雄辩的模特拿来
JavaScript - Fetch实现短信验证码注册登录完整示例:JavaScript - Fetch.js和附件说明
d3-fetch:这个模块提供基于Fetch之上的便捷解析
在mysql数据库连接时碰到Warning: mysql_fetch_array() expects …错误提示,根据我的经验这个是sql返回的query为空了,我们没有加己判断直接使用了. mysql_fetch_array()函数导致的,下面我们一起来看问题解决方案,我...