Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CTAS using dbms_metadata.get_ddl for Partitioned table

chakraApr 30 2012 — edited May 1 2012
Hi,
I would like to create a temporary table from a partitioned table using CTAS. I plan to use the following steps in a PL/SQL procedure:
1. Use dbms_metadata.get_ddl to get the script
2. Use raplace function to change the tablename to temptable
3. execute the script to get the temp table created.

SQL> create or replace procedure p1 as
2 l_clob clob;
3 str long;
4 begin
5 SELECT dbms_metadata.get_ddl('TABLE', 'FACT_TABLE','USER1') into l_clob FROM DUAL;
6 dbms_output.put_line('CLOB Length:'||dbms_lob.getlength(l_clob));
7 str:=dbms_lob.substr(l_clob,dbms_lob.getlength(l_clob),1);
8 dbms_output.put_line('DDL:'||str);
9 end;
12 /

Procedure created.

SQL> exec p1;
CLOB Length:73376
DDL:

PL/SQL procedure successfully completed.


I cannot see the DDL at all. Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 29 2012
Added on Apr 30 2012
11 comments
1,477 views