Hi
Could someone help me with this While Loop Procedure. Need to iterate data one by one from table and insert something in other table. There is something wrong in my procedure now
---------------------------------------
select * from LOOP_TEST
ID
2
3
4
5
8
12
---------------------------------------
BEGIN_PROC
DECLARE
rownum integer;
custid integer;
BEGIN
custid := SELECT max(id) FROM LOOP_TEST;
rownum := SELECT count(id) FROM LOOP_TEST;
while rownum > 0 loop
INSERT INTO loop_test_2
values(1);
SELECT id FROM LOOP_TEST
WHERE id = custid
ORDER BY id DESC
LIMIT 1;
rownum := rownum-1;
END loop;
COMMIT;
END;
END_PROC;
--------------------------------------------------------------------