Home » SQL & PL/SQL » SQL & PL/SQL » Procedure for creating a user
Procedure for creating a user [message #35643] Wed, 03 October 2001 09:21 Go to next message
Raj
Messages: 411
Registered: November 1998
Senior Member
Hi,

I'm a total newbie in Oracle and trying to learn it. I was trying to create a procedure for creating a user by assigning a username and password and adding this user to the sys.user$ table.

I tried writing a procedure with create user xyz identified by abc statements but I'm getting an error while compiling. Are you not allowed to use SQL commands in procedures?

Could somebody tell me how to go about this?

Thanks,

Raj

----------------------------------------------------------------------
Re: Procedure for creating a user [message #35644 is a reply to message #35643] Wed, 03 October 2001 09:34 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You need to use dynamic SQL to accomplish this. Here is an example using native dynamic SQL (8.1.x and higher only):

create or replace procedure create_user
(p_user in varchar2, p_password in varchar2)
is
begin
execute immediate 'create user ' || p_user || ' identified by ' || p_password;
end;
/

----------------------------------------------------------------------
Previous Topic: subprograms in pl/sql
Next Topic: DBMS_SHARED_POOL.UNKEEP
Goto Forum:
  


Current Time: Sat May 25 02:21:47 CDT 2024