Ispirer Website Ispirer Capabilities - Oracle Migration Free Trial

Oracle FOR LOOP to HiRDB

SQLWays changes FOR LOOP statement to WHILE statement. Before WHILE statement SQLWays declares INT variable and sets it lower value of loop range. This variable is incremented by 1 in WHILE statement on each iteration. WHILE loop will work till this variable less or equal when upper value of loop range.

Oracle:

BEGIN 
 <<label_name>> 
 FOR i IN 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 = 2; 
label_name: 
 WHILE (i <= 5) DO 
    insert into dept2(deptno) values(i); 
    SET i = i+1; 
 END WHILE label_name; 
 END;
 END_PROC

© 1999-2024, Ispirer Systems, LLC. All Rights Reserved.