dimanche 1 avril 2018

Stored Procedure never completes execution - Oracle

I have table, which is having 26 columns and is 1TB in size. I am trying to use the following stored procedure to delete the records from this table randomly:

declare cnt number;
BEGIN
    FOR x IN 1 .. 2 LOOP
         SELECT RUN_VER_ISSUE_ID into cnt FROM MV_RUN_VER_IES SAMPLE (0.00091) WHERE ROWNUM <=1;
         DELETE FROM MV_RUN_VER_IES WHERE RUN_VER_ISSUE_ID = cnt;
    END LOOP;
    commit;
END;
/

But the issue is the above loop just goes into infinite execution loop and never completes. I am not sure what I am trying to do wrong here. The reason I say that, when I execute this SQL:

SELECT RUN_VER_ISSUE_ID FROM MV_RUN_VER_IES SAMPLE (0.00091) WHERE ROWNUM <=1;

It executes in fraction of a second. Also the column RUN_VER_ISSUE_ID is a primary key column in the table.

I would request you guys to kindly look into this and please share your comments.




Aucun commentaire:

Enregistrer un commentaire