gpt4 book ai didi

sql - 异常 ORA-08103 : object no longer exists on using setfetchsize of Hibernate

转载 作者:行者123 更新时间:2023-12-02 03:03:38 27 4
gpt4 key购买 nike

我正在使用 hibernate 。我需要获取大约 1000000 条记录,这会导致超时异常。因此,我对 6000 条记录使用 setfetchsize,以便它将操作分配到多个事务中,每个事务处理 6000 条记录。

获取全部内容大约需要 21 小时。

但是在检索记录的同时,如果有人删除了要获取的记录之一,那么我会得到ORA-08103:对象不再存在

现在我想跳过检索时删除的对象。我怎样才能做到这一点?

最佳答案

很可能是基于全局临时表 (GTT) 打开游标,该表是使用 ON COMMIT DELETE ROWS 选项创建的。 ORA-08103:对象不再存在错误的原因是紧随在delete语句之后的commit语句。这是一个简单的例子:

 SQL> declare
2 type t_recs is table of number;
3 l_cur sys_refcursor; -- our cursor
4 l_rec t_recs;
5
6 begin
7
8 -- populating a global temporary table GTT1 with sample data
9 insert into GTT1(col)
10 select level
11 from dual
12 connect by level <= 1000;
13
14 open l_cur -- open a cursor based on data from GTT1
15 for select col
16 from GTT1;
17
18 -- here goes delete statement
19 -- and
20 commit; <-- cause of the error. After committing all data from GTT1 will be
21 -- deleted and when we try to fetch from the cursor
22 loop -- we'll face the ORA-08103 error
23 fetch l_cur -- attempt to fetch data which are long gone.
24 bulk collect into l_rec;
25 exit when l_cur%notfound;
26 end loop;
27
28 end;
29 /


ORA-08103: object no longer exists
ORA-06512: at line 24

使用on commit keep rows子句重新创建全局临时表将允许从基于该表的游标安全地获取数据,而不必担心遇到ORA-08103: 错误。

关于sql - 异常 ORA-08103 : object no longer exists on using setfetchsize of Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18747649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com