不太懂pro*c,不过从oracle的错误说明文档来看,应该是cursor定义的问题。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.
错误信息是说 你还没有分析或执行该语句,就试图fetch 或者是不是你的EXEC SQL OPEN C ;出错了?
我认为错误也不应是open cursor时出的错。
前面的语句应该没问题,因为我这个程序已经正常运行整整一年了,不过还是请大家看一下。程序的主体就是一个循环,每次读出N条记录到book数组strcpy((char *)dynstmt.arr, "SELECT c_dutyname,c_isbn,c_askbookno,c_publisher,d_publishdate FROM tbpb_centerbook WHERE "); strcat((char *)dynstmt.arr,where_clause); dynstmt.len = (unsigned short)strlen((char *)dynstmt.arr); #if 0 printf("<p>%s",(char *) dynstmt.arr); #endif EXEC SQL PREPARE S FROM :dynstmt;
谢谢 xbin999(xbin) ,“I have seen this problem when the client version of Oracle is newer than the server version”你提供的信息对我很有用,若是如此,我就不得不装一个高版本的服务器了,我将100分作为感谢 谁能提供不需重装,我将另外提供200分
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.
你还没有分析或执行该语句,就试图fetch
或者是不是你的EXEC SQL OPEN C ;出错了?
c_dutyname,c_isbn,c_askbookno,c_publisher,d_publishdate FROM tbpb_centerbook WHERE ");
strcat((char *)dynstmt.arr,where_clause); dynstmt.len = (unsigned short)strlen((char *)dynstmt.arr);
#if 0
printf("<p>%s",(char *) dynstmt.arr);
#endif EXEC SQL PREPARE S FROM :dynstmt;
Maybe it's useful.
谁能提供不需重装,我将另外提供200分