Quantcast
Viewing latest article 3
Browse Latest Browse All 717

How to get the DDL for Oracle object without extra characters

When using Oracle’s dbms_metadata.get_ddl for getting DDL I see some extra characters, especially there are whitespace characters at very beginning of DDL script.
For example, if I create this sample procedure:

CREATE OR REPLACE PROCEDURE TEST
IS 
BEGIN
 NULL;
END;
/ 

then dbms_metadata.get_ddl for this procedure returns extra newline and two space characters at very beginning:

select dbms_lob.substr(dbms_metadata.get_ddl('PROCEDURE','TEST', USER), 37, 1 ) text
, dump(dbms_lob.substr(dbms_metadata.get_ddl('PROCEDURE','TEST', USER), 37, 1 )) dump_text
FROM dual;

Result is:
  CREATE OR REPLACE PROCEDURE "TEST"                                            
Typ=1 Len=37: 10,32,32,67,82,69,65,84,69,32,79,82,32,82,69,80,76,65,67,69,32,80,
82,79,67,69,68,85,82,69,32,34,84,69,83,84,34

As you can see there are 10,32,32,, just before CREATE OR REPLACE.
Any idea how to get rid of these whitespaces?
Also there are extra " around procedure name.


Viewing latest article 3
Browse Latest Browse All 717

Trending Articles