Commit In loop gives wrong output?
Posted
by Vineet
on Stack Overflow
See other posts from Stack Overflow
or by Vineet
Published on 2010-04-10T18:05:41Z
Indexed on
2010/04/10
18:13 UTC
Read the original article
Hit count: 162
I am trying to insert 1 to 10 numbers except 6and 8 in table messages,but when i fetch it from table mesages1, output is coming in this order 4 5 7 9 10 1 2 3 It should be like this 1 2 3 4 5 7 9 10 According to the logic ,it works fine when i omit commit or put it some where else, Please explain why it is happening? this is my code.
BEGIN
FOR i IN 1..10
LOOP
IF i<>6 AND i<>8
THEN
INSERT INTO messages1
VALUES (i);
END IF;
commit;
END LOOP;
END;
select * from messages1;
© Stack Overflow or respective owner