簡體   English   中英

在oracle11g中插入行后發生回退的奇怪錯誤

[英]Strange error inserting rows followed by a rollback in oracle11g

編寫腳本來測試(待編寫)觸發器,但是如果回滾更改,則會收到一條奇怪的錯誤消息。 這是測試腳本

    insert into prescription values(
  143, 115, 
  to_date('January 15, 1989, 11:00 A.M.',
  'Month dd, YYYY, HH:MI A.M.',
  'NLS_DATE_LANGUAGE = American'),
  5, 12, 'hours', 12);
select * from prescription;
rollback;

在select語句返回的行中滾動大約一半后,表蒸發,並且出現錯誤消息:

ORA-01002: fetch out of sequence
01002. 00000 -  "fetch out of sequence"
*Cause:    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.
*Action:   1) Do not issue a fetch statement after the last row has been
           retrieved - 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.

如果我在沒有回滾的情況下運行腳本,然后分別發出回滾,則一切正常。 但這將使以后的測試單元變得煩人。

發現問題了! 事實證明,默認情況下oracle SQL開發人員一次僅返回50行。 因此,當我開始向下滾動時,它將關閉並獲取接下來的50行,這可能導致無效的結果,因為選擇是在回滾之前發出的,並且出現錯誤。 通過進入preference-> database並更改返回大小來解決,幸運的是,對我來說,返回大小剛好在它們允許的最大數量之內(200個結果)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM