1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Execute immediate.,.

Discussion in 'SQL PL/SQL' started by Vicky, Jun 18, 2014.

  1. Vicky

    Vicky Forum Advisor

    Messages:
    261
    Likes Received:
    11
    Trophy Points:
    260
    Location:
    Chennai
    Could you tell me how and where to use 'Execute Immediate' in PL/SQL, with exampls.,.

    I heard it should be used while using DDL and DCL statements in Pl/sql block.,
     
  2. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    for example we want create a table through pl sql...

    declare
    v varchar2(100);
    begin
    create table tab2(a number(10));
    end;

    It will give error.

    So if you use below code then it will create table.

    declare
    v varchar2(100);
    begin
    EXECUTE IMMEDIATE 'create table tab2(a number(10))';
    end;
     
    Vicky likes this.
  3. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Vicky likes this.