Home > database >  Strives for the big help
Strives for the big help

Time:09-19

The create or replace procedure job_proc is
CURSOR pcursor is
Select ID, formmain_id, sort the from formson_0021 where FIELD0010 is null order by sort for update.
OrgidCursor pcursor % rowtype; - define types as pcursor row data variable
V_id FORMSON_0021. FORMMAIN_ID % type;
F_id FORMSON_0021. FORMMAIN_ID % type;
F_sort FORMSON_0021. Sort % type;
F_id_10 FORMSON_0021. FIELD0010 % type;
The begin
F_id:=0;
F_sort:=0;
F_id_10:=0;
The open pcursor; - open the cursor
Loop
The fetch pcursor
Into orgidCursor; - the cursor data into pcursor variable
Exit the when pcursor % notfound;
V_id:=orgidCursor. Id;
If (v_id is null) then, v_id tables, which may be empty inside t.org id is empty
null;
The else
The select field0010 into f_id_10 from formson_0021 where formmain_id=orgidCursor. Formmain_id and sort=orgidCursor. Sort - 1;
Update formson_0021 x set x.f ield0010=f_id_10 + field0009 field0013 where formmain_id=orgidCursor. Formmain_id and sort=orgidCursor. Sort;
commit;
end if;
end loop;
The close pcursor;
end;


The error log:
Line: 2 begins to execute commands on error -
Call job_proc ()
Error reporting -
SQL error: ORA - 01002:
extraction in violation of the orderORA - 06512: the "SEEYON JOB_PROC", line 15
01002. In 00000 - "the fetch out of sequence"
* Cause: This error means that a fetch has had attempted the 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, o:
1) Fetching the from a cursor after the last row has had retrieved
And the ORA - 1403 error returned.
2) If the cursor has had the opened with the FOR UPDATE clause,
Fetching after a COMMIT has had 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 had
Retrieved - there are no more rows to fetch.
2) Do not issue a COMMIT inside the fetch a loop for a cursor
That has had the opened FOR UPDATE.
3) Reexecute the statement after rebinding, then attempt to
The fetch again.

CodePudding user response:

 update formson_0021 t1 
The set t1. Field0010=(select t2. Field0010 + t2. Field0009 - t2. Field0013
The from formson_0021 t2
Where a t1. Formmain_id=t2. Formmain_id and t1. Sort=t2. Sort - 1)
Where a t1. FIELD0010 is null
;

CodePudding user response:

Should be to exit the when pcursor % notfound; Put in the right place, can look at: https://blog.csdn.net/suojie123/article/details/79299058
  • Related