Re: Creating users via PL/SQL

From: Thomas Dunbar <tdunbar_at_gserver.grads.vt.edu>
Date: 1995/10/24
Message-ID: <46j9hc$1l0_at_solaris.cc.vt.edu>#1/1


gag_at_objectworks.com (GAG) wrote:
>You can't put DCL or DDL into stored programs.
>
>Thus no create ( DDL ) and no grant ( DCL ).

sure you can..just need to use dynamic sql. for example:

   procedure create_user(user_i in varchar2, pw_i in varchar2) is

        cur integer;
        str varchar2(200);
        ret integer;
     begin
        str:='create user '||user_i||' identified by '||pw_i||
              ' default tablespace users temporary tablespace temp';
        cur:=dbms_sql.open_cursor;
        dbms_sql.parse(cur,str,dbms_sql.v7);
        ret:=dbms_sql.execute(cur);
        dbms_sql.close_cursor(cur);
     end;

of course the user running the procedure has to have been granted the create user privilege.

-- 
Thomas Dunbar    540 231-3938    http://gserver.grads.vt.edu/
Received on Tue Oct 24 1995 - 00:00:00 CET

Original text of this message