Dear All,
I have a piece of code for deleting data from a table based on a range specified.
Unfortunately, even though I have limited the package size of the cursor and have a COMMIT WORK within the loop, the undo tablespace just gets filled up and terminates with a ORA-01555 Error after running for 2-3 hours.
The Undo Tablespace size is 30GB with AUTOEXTEND = OFF (this unfortunately cannot be changed).
Kindly take a look at the below code and suggest how to go about resolving this error.
Thanks & Best Regards,
Suman
----------------------------------------------------------------------------------------------------------------------------------------------------------------
OPEN CURSOR WITH HOLD l_cursor FOR SELECT * FROM (ls_delete_tables-tabname)
WHERE plvar EQ ls_otype_plvar-plvar AND otype EQ ls_otype_plvar-otype ORDER BY PRIMARY KEY.
DO.
FETCH NEXT CURSOR l_cursor
INTO TABLE <fs> PACKAGE SIZE lv_num_of_rows.
* If no data is found, then exit
IF sy-subrc <> 0.
EXIT.
ENDIF.
* 6.1.2 Read the target range for the given plvar / otype
READ TABLE lt_targets INTO ls_targets
WITH KEY otype = ls_otype_plvar-otype
plvar = ls_otype_plvar-plvar.
* 6.1.3 Delete data that does not belong to the given target range
LOOP AT <fs> ASSIGNING <fs_line>.
ASSIGN COMPONENT 'OBJID'
OF STRUCTURE <fs_line>
TO <fs_field>.
IF <fs_field> IS ASSIGNED.
IF <fs_field> LT ls_targets-objid_from OR
<fs_field> GT ls_targets-objid_to.
DELETE TABLE <fs> FROM <fs_line>.
ENDIF.
ENDIF.
ENDLOOP.
* 6.1.4 Delete data from the database table
DELETE (ls_delete_tables-tabname) FROM TABLE <fs>.
EXEC SQL.
COMMIT WORK.
ENDEXEC.
ENDDO.