Ispirer Website
Ispirer Capabilities - Oracle Migration
Free Trial
Oracle FOR LOOP … IN REVERSE to HiRDB
SQLWays changes FOR LOOP REVERSE statement to WHILE statement. Before WHILE statement SQLWays declares INT variable and sets it upper value of loop range. This variable is decremented by 1 in WHILE statement on each iteration. WHILE loop will work till this variable more or equal when lower value of loop range.
Oracle:
BEGIN <<label_name>> FOR i IN REVERSE 2 .. 5 LOOP insert into dept2(deptno) values(i); END LOOP label_name; END ;
HiRDB:
CREATE PROCEDURE for_loop() LANGUAGE SQL BEGIN DECLARE i INT; SET i = 5; label_name: WHILE (i >= 2) DO insert into dept2(deptno) values(i); SET i = i-1; END WHILE label_name; END; END_PROC