Well, today, I stumbled across 10 active database sessions, all from the same user, all running an anonymous PL/SQL block issued within SQL Commands on apex.oracle.com. All 10 sessions had been running for hundreds of seconds and all 10 were in the APEX_LOW resource consumer group. By using the built-in-to-APEX Utilities -> Database Monitor -> Sessions reports, I was able to determine exactly what was executing in these sessions.
What's wrong with this user's code?
DECLARE
i NUMBER(3):=1;
BEGIN
WHILE (i<5) LOOP
IF( mod(i,2)=0) THEN
DBMS_OUTPUT.PUT_LINE(i);
END IF;
END LOOP;
END;
I am NOT suggesting you run this on apex.oracle.com nor your own instance of Application Express.
8 comments:
The value "i" is not incremented.
So this is results in infinite loop.
--Chandra.
If I had a nickel for every time I forgot to increment a loop... I'd have a couple dollars anyway! Let's just say that I've made this mistake often enough that it was easy to recognize...
Thanks for the tip about the Resource Manager.
There was a time when the DBMS_OUTPUT buffer was small enough that it would fall over. Then they go and 'enhance' it :)
As Chandu already pointed to, your variable i isn't de/incremented. So your loop is indefinite.
Andreas,
This is definitely *not* "my variable" nor "my loop".
Joel
I've tried running this code 5-6 times now, and can't figure out what's wrong, other than it broke my database and my internets. :)
- Scott -
Scott is a smart-@$$
Scott - You too??? My DBAs are really mad at me.
Doug - What do you mean?
;-)
Post a Comment