How to call DDL statements from pl/sql?

Answer Posted / kavitha nedigunta

set serveroutput on;
DECLARE
CNT NUMBER;
table_name varchar2(300) := 'testnew';
BEGIN
--EXECUTE IMMEDIATE ('grant create table to user_name');
EXECUTE IMMEDIATE ('create table '||table_name||'(name
varchar2(10))');

SELECT COUNT(*) INTO CNT FROM USER_OBJECTS WHERE OBJECT_NAME = upper(''||table_name||'');

IF cnt > 0 THEN
dbms_output.put_line('Table Created');
END IF;

EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Name is already used by an existing object');
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define overloaded procedure?

626


Explain the difference between drop and truncate commands in sql?

540


Inline the values in PL/SQL, what does it mean.?

635


how to return query output in html format? : Sql dba

656


what is a trigger in mysql? : Sql dba

609






What are the rules to be applied to nulls whilst doing comparisons?

756


Does truncate remove indexes?

565


What are the different type of joins in sql?

544


what is myisam? : Sql dba

580


How you can copy a file to file content and file to pl/sql table in advance pl/sql?

624


What is the purpose of design view?

531


how many groups of data types? : Sql dba

572


What is a scalar value in sql?

594


What is Collation Sensitivity ? What are the various type ?

501


how would concatenate strings in mysql? : Sql dba

576