Within a shell script I am using a pl/sql block to drop certain users using $USER parameter. If another parameter ${DROP_AB} is Y then drop all users from the cursor. How do I drop all users except one specific user ${USER}AB if the parameter passed is N? Please see below and help with suggestions:
BEGIN
DECLARE
CURSOR c1 IS
SELECT username FROM dba_users WHERE username LIKE '${USER}%';
BEGIN
FOR user_rec IN c1
IF ${DROP_AB}='Y' THEN
LOOP
EXECUTE IMMEDIATE 'DROP USER ' ||user_rec.username|| ' CASCADE';
ELSIF ${DROP_AB}='N' THEN
LOOP
--DROP ALL USERS EXCEPT FOR USER '${USER}AB'
END LOOP;
END;
END;
/