{"id":31014,"date":"2023-08-30T13:22:49","date_gmt":"2023-08-30T05:22:49","guid":{"rendered":"http:\/\/www.idc.net\/help\/31014\/"},"modified":"2023-08-30T13:22:49","modified_gmt":"2023-08-30T05:22:49","slug":"ora-01002-fetch-out-of-sequence-oracle-%e6%8a%a5%e9%94%99-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%a4%8d-%e8%bf%9c%e7%a8%8b%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/31014\/","title":{"rendered":"ORA-01002: fetch out of sequence ORACLE \u62a5\u9519 \u6545\u969c\u4fee\u590d \u8fdc\u7a0b\u5904\u7406"},"content":{"rendered":"<h3>\u6587\u6863\u89e3\u91ca<\/h3>\n<p><span>ORA-01002:<\/span> fetch out of sequence<\/p>\n<p><span>Cause:<\/span> This error means that a fetch has been attempted from a cursor which is no longer valid. Note that a PL\/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including: 1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned. 2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error. 3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.<\/p>\n<p><span>Action:<\/span> 1) Do not issue a fetch statement after the last row has been retrieved \u2013 there are no more rows to fetch. 2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE. 3) Reexecute the statement after rebinding, then attempt to fetch again.<\/p>\n<\/p>\n<p>## ORA-01002: fetch out of sequence<\/p>\n<p>ORA-01002: fetch out of sequence \u662fOracle\u6570\u636e\u5e93\u4e2d\u4e00\u4e2a\u901a\u7528\u7684\u9519\u8bef\u4ee3\u7801\uff0c\u8be5\u9519\u8bef\u8868\u660e\u5f53\u524d\u64cd\u4f5c\u88ab\u4e2d\u65ad\uff0c\u56e0\u4e3a\u5728\u4ee4\u4e00\u4e2a\u975e\u6cd5\u7684fetch\u64cd\u4f5c\u4e2d\uff0c\u5e94\u7528\u7a0b\u5e8f\u8bd5\u56fe\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u4e00\u884c\u6570\u636e\uff0c\u800c\u4e0d\u662f\u5e94\u8be5\u5148\u6267\u884c\u7684open\u64cd\u4f5c\u3002<\/p>\n<h3>\u5b98\u65b9\u89e3\u91ca<\/h3>\n<h3>\u5e38\u89c1\u6848\u4f8b<\/h3>\n<p>\u8fd9\u4e2a\u9519\u8bef\u7684\u5e38\u89c1\u539f\u56e0\u662f\u5728\u4e00\u4e2aPL\/SQL\u5757\u4e2d\uff0c\u7528\u6237\u5728\u6267\u884cFETCH\u64cd\u4f5c\u4e4b\u524d\u6ca1\u6709\u5148\u6267\u884cOPEN\u64cd\u4f5c\uff0c\u6216\u8005\u5728CUrsor\u4e0a\u6267\u884c\u4e86\u4e24\u6b21OPEN\u64cd\u4f5c\u3002 \u8fd9\u4f1a\u5bfc\u81f4\u6e38\u6807\u5df2\u7ecf\u5173\u95ed\uff0c\u7ed3\u679c\u5728\u6267\u884cFETCH\u4e4b\u524d\uff0c\u4e0d\u80fd\u83b7\u53d6\u6253\u5f00\u6e38\u6807\uff0c\u4ece\u800c\u5bfc\u81f4ORA-10002: fetch out of sequence \u9519\u8bef\u6d88\u606f\u51fa\u73b0\u3002<\/p>\n<h3>\u6b63\u5e38\u5904\u7406\u65b9\u6cd5\u53ca\u6b65\u9aa4<\/h3>\n<p>1.\u786e\u5b9a\u9519\u8bef\u53d1\u751f\u7684PL\/SQL\u5757\uff1b <\/p>\n<p>2.\u68c0\u67e5\u9519\u8bef\u53d1\u751f\u5904\uff0c\u770b\u662f\u5426\u5728FETCH\u64cd\u4f5c\u4e4b\u524d\u786e\u5b9e\u5b58\u5728OPEN\u64cd\u4f5c\uff1b <\/p>\n<p>3.\u5982\u679c\u5b58\u5728\u6e38\u6807\u672a\u5173\u95ed\u7684\u60c5\u51b5\uff0c\u5b9e\u65bd\u76f8\u5e94\u7684\u51fd\u6570\uff0c\u5982 CLOSE CURSOR \u7b49\u64cd\u4f5c\u5c06\u4e4b\u524d\u7684\u6e38\u6807\u5173\u95ed\uff1b <\/p>\n<p>4.\u91cd\u65b0\u7f16\u8bd1PL\/SQL\u8bed\u53e5\u5757\uff0c\u91cd\u65b0\u6267\u884c\u3002<\/p>\n<p>\u9999\u6e2f\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91\uff0c2H2G\u9996\u670810\u5143\u5f00\u901a\u3002<br \/>\u540e\u6d6a\u4e91\uff08www.IDC.Net\uff09\u63d0\u4f9b\u7b80\u5355\u597d\u7528\uff0c\u4ef7\u683c\u539a\u9053\u7684\u9999\u6e2f\/\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\u548c\u72ec\u7acb\u670d\u52a1\u5668\u3002IDC+ISP+ICP\u8d44\u8d28\u3002ARIN\u548cAPNIC\u4f1a\u5458\u3002\u6210\u719f\u6280\u672f\u56e2\u961f15\u5e74\u884c\u4e1a\u7ecf\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u6863\u89e3\u91ca ORA-01002: fetch out of sequence Cause: This error [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-31014","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/31014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=31014"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/31014\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=31014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=31014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=31014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}