How to call DDL statements from pl/sql?

Answer Posted / parag tyagi

CREATE OR REPLACE PROCEDURE emp_test( in_name VARCHAR2) IS
cnt NUMBER;
BEGIN
EXECUTE IMMEDIATE ('grant create table to user_name');
EXECUTE IMMEDIATE ('create table ' || in_name || '(name
varchar2(10))');
SELECT '1' INTO cnt FROM User_Objects WHERE object_name
= 'EMP_TEST';
IF cnt IS NOT NULL 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 ?    6 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the example of procedure?

506


How to fetch alternate records from a table?

671


What is a heap in sql?

517


what are the different functions in sorting an array? : Sql dba

574


Why do we need databases?

557






What is substitution variable?

570


Does db2 use sql?

502


What type of database is sql?

609


What is a table in a database?

565


What is a primary key example?

507


- Types of triggers - View - Dcl - Procedures, packages, functions - Metasolve - Can use Dcl in triggers - package case study - Cursor and its types - triggers schedule - Wrap - Why we are using fetch and for in cursor. difference?

1378


What is native sql query?

542


What are the different types of joins in sql?

575


What is the difference between join and natural join?

466


what happens if null values are involved in expressions? : Sql dba

557