Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Posts
    77

    Unanswered: Include Variables witihin a DDL in pl/sql block

    I have to create 50 user accounts,

    I am trying use the following code



    declare

    fname varchar2(10);

    begin
    for x in 1 .. 500 loop
    fname:= concat('User_',x);
    create user fname identified by password;
    end loop;
    end;



    my question is how do I include the fname variable within the DDL statement thanks

  2. #2
    Join Date
    Jan 2003
    Location
    Woking
    Posts
    107

    Re: Include Variables witihin a DDL in pl/sql block

    Originally posted by vld
    I have to create 50 user accounts,

    I am trying use the following code



    declare

    fname varchar2(10);

    begin
    for x in 1 .. 500 loop
    fname:= concat('User_',x);
    create user fname identified by password;
    end loop;
    end;



    my question is how do I include the fname variable within the DDL statement thanks

    Hi,

    You have to use DBMS_UTILITY.EXEC_DDL_STATEMENT
    or Execute Immediate



    declare

    fname varchar2(10);
    stmt varchar2(4000);

    begin
    for x in 1 .. 500 loop
    fname:= concat('User_',x);
    stmt := 'create user '||fname||' identified by password';
    DBMS_UTILITY.EXEC_DDL_STATEMENT( stmt );
    end loop;
    end;


    Hope it Helps.
    nn

  3. #3
    Join Date
    Jan 2002
    Posts
    77
    Thanks a bunch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •