-
I'm trying to insert a record into a table if the data doesn't exist...pretty simple I think but the syntax eludes me...
Here's what I have. When I execute the query, the procedure
spins out of control.
create or replace procedure insert_utest
(p_username IN varchar2)
IS
v_username varchar2(5);
CURSOR get_user IS
SELECT username FROM utest
WHERE username=p_username;
BEGIN
OPEN get_user;
LOOP
FETCH get_user into v_username;
IF get_user%NOTFOUND THEN
insert into utest values (v_username);
commit;
ELSE
dbms_output.put_line('User ' ||v_username|| ' exists');
exit;
END IF;
END LOOP;
CLOSE get_user;
END;
???
Running the query does not return and generates a ton
of redo. I can't see to find the problem????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|