结果一样:fetch out of sequence
解决方案 »
- 数据的转移
- 有关数据库连接查询
- Oracle样本数据库
- 复杂SQL求教
- 求救!! 为什么我调用过程时,会出现ORA-20003。我从新编译后,可以了。不久又出现ORA-20003???
- 上线时遇到字符集问题,高手请入,急!在线给分!
- 现在有一个收入记录表,每条记录为某个月的某个项目的收入,我想选出某个月中,收入比上月下滑的项目(统计出项目名称,这个月收入,上个
- .net 调用oracle 编写的存储过程,怎样得到表的集合
- 关于游标中where current of 的疑问,请高手指教,谢谢
- JAVA+linux+oracle应用时快时慢,请求各位大神帮忙解决,谢谢!
- 我在那里可以看到我建立的触发器?
- 返回记录集的问题 -在线等
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.
下面这个例子供你参考:
void main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *uid= "qhdcrd/qhdcrd@ora9";
int empnum;
varchar rowident[ 30 ];
EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO sqlerr( );
EXEC SQL CONNECT :uid;
printf( "\nConnected to ORACLE\n" ); EXEC SQL DECLARE c1 CURSOR FOR
SELECT rowid, empno FROM ora1002tab;
EXEC SQL OPEN c1; EXEC SQL WHENEVER NOT FOUND DO break;
while( 1 == 1 )
{
EXEC SQL FETCH c1 INTO :rowident, :empnum;
EXEC SQL UPDATE ora1002tab SET empno = :empnum + 50
WHERE rowid = :rowident;
if( sqlca.sqlcode )
printf( " attention here : fail - [%ld] ", sqlca.sqlcode ) ;
EXEC SQL COMMIT;
} /* end while */ EXEC SQL CLOSE c1;
EXEC SQL COMMIT WORK RELEASE; /* logoff database */
exit(0);
} /* end main( ) */
void sqlerr( void )
{
EXEC SQL WHENEVER SQLERROR CONTINUE; printf("\nORACLE error detected:\n");
printf("\n% .70s \n", sqlca.sqlerrm.sqlerrmc); EXEC SQL ROLLBACK RELEASE;
exit(1);
} /* end sqlerr( ) */但如果你没用oracle的commit而用了其他方式提交事物,这个办法可能不行了。