I tried something like this to drop user from Oracle DB.
create or replace procedure skeleton1(inUser varchar) IS
begin
set @str = concat('drop user ', "'",inUser,"'@","'localhost'");
prepare stmt from @str;
-- select @str;
execute IMMEDIATE stmt;
deallocate prepare stmt;
end//
delimiter ;
But I am facing multiple compilation error.
Can somone please help?
Little of what you have is valid Oracle syntax. I’d suggest you start reading the PL/SQL documentation before you try to do anything potentially destructive like this. Maybe start here and see where it takes you.
I’m slightly reluctant to give a direct answer, but you’ll get it from somewhere; so you can do something like:
But you need to sanitise your inputs to really make sure it can’t be abused, and you really need to understand what you are doing and what effect it could have. Just as one example, this will fail if the user owns any objects.