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.
[Quote=引用 8 楼 minitoy 的回复:]
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 a……
[/Quote]
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.
不知道java里怎么用cursor.不过plsql里是这样用的.
open cursorname;
loop
fetch cursorname into varlist;
exit when cursorname%notfound;
do something;
end loop;
close cursorname;
这是我的存储过程
procedure createSmsData(v_result out ref_cur,v_deptId in varchar2)is
tempSql varchar2(2000) := '';
begin
tempSql:='select t."leaveTime" std,m."psc" userid,m."psn" username
from task@REMOTESQL2000 t,chedule@REMOTESQL2000 m
where t."confirm"=0 and t."deptId"='''||v_deptId||'''
and t."tskmark"=m."tsk"
open v_result for tempSql;
end;
其中v_result out ref_cur中的ref_cur是在包中定义的游标变量type ref_cur is ref cursor;
返回的游标,我在java中做循环取值java部分代码
conn.setAutoCommit(false);
……
rs = (ResultSet) cstmt.getObject(1);
while (rs.next())
{
……[这里只是简单的取值]
}
……
finally
{
free(conn, cstmt, rs);--调用方法关闭conn、cstmt、rs
}
不知道应该还要修改什么地方