Friday, September 11, 2009

Execute Immediate

CREATE OR REPLACE PROCEDURE create_user (
p_user_name VARCHAR2,
p_passward VARCHAR2
) IS
BEGIN
EXECUTE IMMEDIATE ' CREATE USER '
|| p_user_name
|| ' IDENTIFIED BY '
|| p_passward;

EXECUTE IMMEDIATE ' CREATE ROLE MAN3 ';

EXECUTE IMMEDIATE 'GRANT CREATE SESSION,CREATE TABLE,CREATE PROCEDURE TO MAN3';

EXECUTE IMMEDIATE ' GRANT MAN3 TO ' || p_user_name;
END;

SQL> /

Procedure created.

SQL> EXEC CREATE_USER('BASE4', 'BASE4');

PL/SQL procedure successfully completed.

No comments: