Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a large oracle SQL script in a loop

Tags:

sql

oracle

sas

I have created a large piece of script which inserts new rows at the very end into my target table.

Script contains many select statements and interim tables.

I want to loop it to run 2000 times consecutively and can't see any alternative than pushing f5 2000 times.

Is there a Oracle SQL equivalent of wrapping the code into SAS macro and looping it 2000 times?

like image 941
user6840188 Avatar asked Oct 30 '22 17:10

user6840188


1 Answers

PL/SQL anonymous block is best in this situation:

BEGIN
    FOR i IN 1..2000 LOOP
        -- Insert scripts go here
    END LOOP
END;
/
like image 139
Gurwinder Singh Avatar answered Nov 09 '22 16:11

Gurwinder Singh