Three Common Errors (fetch out of sequence, invalid rowid, numeric or value error) in PL/SQL sp)

Source: Internet
Author: User

1. 15:49:23 ORA-01002: fetch out of sequence
the number of records to be fetch is incorrect (for example, there are 8 records but 9 records are fetch)
PS:
. is commit; cause error
when you open a cursor with for update, the system will apply exclusive lock to the retrieved data ),
before the lock is released, other users cannot update, delete, or lock these records.
once I execute commit, the lock is released, the cursor becomes invalid, and an error occurs when I fetch the data.
therefore, you need to put the commit outside the loop, wait until all data processing is complete, and then commit, and then close the cursor
B. cursor cur is select * from table for update;
it's okay to comment out for update, but it's strange that for update is used in other places.

2. 15:49:23 ORA-01002: invalid rowid
records are cleared when the temporary table commit is used.
because the record is empty (but you want to use a cursor ), the row cannot be found. The temporary table is changed to: On commit preserve rows
PS:
● On commit Delete rows table name rows are only visible during the transaction
● On commit preserve rows table name rows are visible during the entire session

3. 19:36:09 ORA-06502: PL/SQL: numeric or value error
varchar type, the assigned value exceeds the defined length.
for example, declare HH varchar2 (4000);
hh: = mm | nn; -- Mm 3564, NN 600
PS:
Possible reasons:
1. if it is an in parameter, it may be that the parameter is assigned a variable with a relatively small length during the process. As a result, the variable cannot store the passed variable value.
2. if it is an out parameter, it may be that the length of the parameter definition in the call process is not enough, that is, it is smaller than the length of the parameter value in the process.
3. A general numeric Conversion error occurs. For example, you can convert a string containing non-numbers to a number.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.