Oracle PL-SQL Question:
Download Questions PDF

How we can create a table in PL/SQL block. insert records into it? is it possible by some procedure or function? please give example?

Answer:

CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)

AS

l_stmt VARCHAR2(200);

BEGIN

DBMS_OUTPUT.put_line('STARTING ');

l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';

execute IMMEDIATE l_stmt;

DBMS_OUTPUT.put_line('end ');

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);

END;

Download Oracle PL-SQL Interview Questions And Answers PDF

Previous QuestionNext Question
In a Distributed Database System Can we execute two queries simultaneously? Justify?How to avoid using cursors? What to use instead of cursor and in what cases to do so?