Is it possable to use the create command in a stored procedure as when I try this I get an error
Create or Replace Procedure Add_User
(p_name all_users.username%TYPE) AS
BEGIN
SELECT * from ALL_USERS;
CREATE TABLESPACE james
DATAFILE '/home/oracle/joy/oradata/joy/james01.dbf' size 10M
DEFAULT STORAGE ( INITIAL 50K NEXT 50K
MINEXTENTS 1
MAXEXTENTS 100
PCTINCREASE 20);
CREATE USER james IDENTIFIED BY passwd
DEFAULT TABLESPACE james;
grant connect to james;
grant resource to james;
Commit;
END Add_User;
the following error is recived:
Errors for PROCEDURE ADD_USER:
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/2 PLS-00103: Encountered the symbol "CREATE" when expecting one of
the following:
begin declare end exception exit for goto if loop mod null
pragma raise return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
<a single-quoted SQL string>
Of course I want to replace usernames with the contents of p_name
Create or Replace Procedure Add_User
(p_name all_users.username%TYPE) AS
BEGIN
SELECT * from ALL_USERS;
CREATE TABLESPACE james
DATAFILE '/home/oracle/joy/oradata/joy/james01.dbf' size 10M
DEFAULT STORAGE ( INITIAL 50K NEXT 50K
MINEXTENTS 1
MAXEXTENTS 100
PCTINCREASE 20);
CREATE USER james IDENTIFIED BY passwd
DEFAULT TABLESPACE james;
grant connect to james;
grant resource to james;
Commit;
END Add_User;
the following error is recived:
Errors for PROCEDURE ADD_USER:
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/2 PLS-00103: Encountered the symbol "CREATE" when expecting one of
the following:
begin declare end exception exit for goto if loop mod null
pragma raise return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
<a single-quoted SQL string>
Of course I want to replace usernames with the contents of p_name