No wonder your procedure spins out of control, you've created an infinite loop.
If you pass to the procedure the username that does not yet exist in your table UTEST, you doesn't have any exit from your loop! It will continue inserting the same name into the table untill it fills the tablespace or you kill the procedure.
To avoid this you could do one of the following things (in the order from worse to better):
1. Put EXIT after your commit in the first part of your if-else dtatement.
2. Why have you tried to use a loop in the first pace? You don't need it at all! Simply remove LOOP and END LOOP as well the existing EXIT after DBMS_OUTPUT and you are done.
3. Create an unique index on UTEST.UNAME (or create unique or primary key constraint), then change your code to:
create or replace procedure insert_utest
(p_username IN varchar2)
IS
BEGIN
insert into utest values (p_username);
commit;
EXCEPTION
WHEN_DUP_VAL_ON_INDEX THEN
dbms_output.put_line('User ' ||p_username|| ' exists');
END;
This code is much simplier, readable and efficient.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Bookmarks