Dbms_metadata.get_ddl and lob columns

Good day, all,
I get the disappointing results, below, when trying to use the 9i dbms_metadata browsing package against a table with a BLOB (or CLOB) column. In other cases, it works fine; so I believe that it is not a "setup" or security problem.
Do you know any magic to get this to work?
Thanks!
Don M.
SQL> create table x (c1 blob);
Table created.
SQL> select dbms_metadata.get_ddl ('TABLE','X','DMAIER') from dual;
ERROR:
ORA-19206: Invalid value for query or REF CURSOR parameter
ORA-06512: at "SYS.DBMS_XMLGEN", line 83
ORA-06512: at "SYS.DBMS_METADATA", line 345
ORA-06512: at "SYS.DBMS_METADATA", line 410
ORA-06512: at "SYS.DBMS_METADATA", line 449
ORA-06512: at "SYS.DBMS_METADATA", line 615
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1

I have gone through some errors with invalid XDB objects when wanted to run dbms_metadata.get_ddl too. That was on 10gR2 (10.2.0.1 - though other instance was installed in "same" manner and everything worked ok). I had to drop and recreate XDK objects again - following some metalink note - I have posted the exact steps on metalink, I think I ran following commands from $ORACLE_HOME/RDBMS/ADMIN
catnomta.sql
catnodp.sql
rmxml.sql
catxml.sql
utlcxml.sql
prvtcxml.plb
catnomta.sql
dbmsmeta.sql
dbmsmeti.sql
dbmsmetu.sql
catemeta.sql
prvtmeta.plb
prvtmeti.plb
prvtmetu.plb
initmeta.sql
catdph.sql
catdpb.sql
initmeta.sql

Similar Messages

  • Dbms_metadata.get_ddl and select_catalog_role

    Hi,
    We have been requested to give support staff the ability to see table triggers, stored procedures, etc only for specific schemas and they don't have access to the schema password. We can't give them SELECT_CATALOG_ROLE because they are not allowed to see all schemas. I wish there were a way to grant a version of SELECT_CATALOG_ROLE for only certain schemas......
    I've played around with dbms_metadata.get_ddl with no luck (as per the documentation, but just had to try it anyway). I've even considered the script below, but it requires creating a view under the SYS schema and I can't figure out how to add triggers to the view.
    Any ideas would be greatly appreciated!
    Thanks,
    Susan
    accept 1 prompt "Enter Owner:"
    create or replace view all_dev_source
    (OWNER, NAME, TYPE, LINE, TEXT)
    as
    select u.name, o.name,
    decode(o.type#, 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
    11, 'PACKAGE BODY', 13, 'TYPE', 14, 'TYPE BODY',
    'UNDEFINED'),
    s.line, s.source
    from sys.obj$ o, sys.source$ s, sys.user$ u
    where
    u.name = upper('&&1') and
    o.obj# = s.obj#
    and o.owner# = u.user#
    and o.type# in (7, 8, 9, 11, 13, 14)
    and
    o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
    or
    (o.type# = 7 or o.type# = 8 or o.type# = 9)
    and
    o.obj# in (select obj# from sys.objauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and privilege# = 12 /* EXECUTE */)
    or
    exists
    select null from sys.sysauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and
    /* procedure */
    (o.type# = 7 or o.type# = 8 or o.type# = 9)
    or
    privilege# = -144 /* EXECUTE ANY PROCEDURE */
    or
    privilege# = -141 /* CREATE ANY PROCEDURE */
         or
    /* package body */
    o.type# = 11 or
    privilege# = -141 /* CREATE ANY PROCEDURE */
    or
    /* type */
    o.type# = 13
    or
    privilege# = -184 /* EXECUTE ANY TYPE */
    or
    privilege# = -181 /* CREATE ANY TYPE */
         or
    /* type body */
    o.type# = 14 and
    privilege# = -181 /* CREATE ANY TYPE */
    union
    select u.name, o.name, 'JAVA SOURCE', s.joxftlno, s.joxftsrc
    from sys.obj$ o, x$joxfs s, sys.user$ u
    where
    u.name = upper('&&1') and
    o.obj# = s.joxftobn
    and o.owner# = u.user#
    and o.type# = 28
    and
    o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
    or
    o.obj# in (select obj# from sys.objauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and privilege# = 12 /* EXECUTE */)
    or
    exists
    select null from sys.sysauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and
    /* procedure */
    privilege# = -144 /* EXECUTE ANY PROCEDURE */
    or
    privilege# = -141 /* CREATE ANY PROCEDURE */
    comment on table all_dev_source is
    'Current source on stored objects that user is allowed to create'
    comment on column all_dev_source.OWNER is
    'Owner of the object'
    comment on column all_dev_source.NAME is
    'Name of the object'
    comment on column all_dev_source.TYPE is
    'Type of the object: "TYPE", "TYPE BODY", "PROCEDURE", "FUNCTION",
    "PACKAGE", "PACKAGE BODY" or "JAVA SOURCE"'
    comment on column all_dev_source.LINE is
    'Line number of this line of source'
    comment on column all_dev_source.TEXT is
    'Source text'
    grant select on all_dev_source to <username>
    /

    user632322 wrote:
    I think I am misunderstanding your reply becauseI had to be more specific. By "privileged user" I meant SYS. SELECT_CATALOG_ROLE is a role itself, so it will be ignored by definer rights SP/SF. That is why it has to be owned by privileged user SYS:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> show user
    USER is "SYS"
    SQL> create user u1 identified by u1 default tablespace users quota unlimited on users
      2  /
    User created.
    SQL> grant create session to u1
      2  /
    Grant succeeded.
    SQL> create or replace
      2    function get_ddl(
      3                     p_type varchar2,
      4                     p_object varchar2,
      5                     p_owner varchar2
      6                    )
      7      return clob
      8      is
      9      begin
    10          return dbms_metadata.get_ddl(p_type,p_object,p_owner);
    11  end;
    12  /
    Function created.
    SQL> grant execute on get_ddl to u1
      2  /
    Grant succeeded.
    SQL> connect u1/u1
    Connected.
    SQL> set serveroutput on
    SQL> exec dbms_output.put_line(dbms_metadata.get_ddl('TABLE','EMP','SCOTT'));
    BEGIN dbms_output.put_line(dbms_metadata.get_ddl('TABLE','EMP','SCOTT')); END;
    ERROR at line 1:
    ORA-31603: object "EMP" of type TABLE not found in schema "SCOTT"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 2806
    ORA-06512: at "SYS.DBMS_METADATA", line 4333
    ORA-06512: at line 1
    SQL> exec dbms_output.put_line(sys.get_ddl('TABLE','EMP','SCOTT'));
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL"
    NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT
    "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
    COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS
    2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS
    1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576
    MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
    BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"
    PL/SQL procedure successfully completed.
    SQL> Now one more correction to my previous reply. Driver table shoudl not be owned by SYS (that would be bad practice). Create it in some other schema. Just make sure your "support staff" has no access to it.
    SY.

  • DBMS_METADATA.GET_DDL and Materialized View

    hi gurus,
    In 10gR2, i have created a materialized view EMP_MV with a simple structure.
    I wanted to get the DDL of EMP_MV.
    I used DBMS_METADATA to get the DDL,
    select DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET') into v_return from dual;
    Output
    CREATE MATERIALIZED VIEW "TARGET"."EMP_MV"
    ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TARGET_TS_01"
    BUILD IMMEDIATE
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TARGET_TS_01"
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS select empid,empname,address from web.emp
    Is there any way to get only SELECT part of this MV, ie select empid,empname,address from web.emp directly from dictionary without any string manipulation?
    tia,
    newbie

    Yes you can do it. By using INSTR and SUBTR against the result of GET_DDL function
    Try this:
    select substr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),instr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),'select'),1000)
    into v_return from dual;- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Problem with DBMS_METADATA.GET_DDL and subpartitions

    I have problems with DBMS_METADATA.GET_DDL in a 11gR2 (11.2.0.3) database on Linux. The following example shows the problem:
    CREATE TABLE Test_tbl
    C1 NUMBER(14),
    C2 NUMBER(14),
    C3 NUMBER(14)
    PARTITION BY RANGE (C1)
    SUBPARTITION BY LIST (C2)
    PARTITION Part1 VALUES LESS THAN (1000)
    , PARTITION Part2 VALUES LESS THAN (2000)
    CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    When I execute
    SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    on a 10g database (10.2.0.2.0) on Solaris Sparc and on a 11.1.0.7 on Windows, it gives the correct DDL statement within some seconds.
    On the 11.2.0.3 database (Linux) it hangs forever.
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    ^CERROR:
    ORA-01013: user requested cancel of current operation
    This behavior only seems to occur in combination with local indexes and subpartitions.
    Anyone any idea?
    Thx, Carsten

    user592634 wrote:
    I have problems with DBMS_METADATA.GET_DDL in a 11gR2 (11.2.0.3) database on Linux. The following example shows the problem:
    CREATE TABLE Test_tbl
    C1 NUMBER(14),
    C2 NUMBER(14),
    C3 NUMBER(14)
    PARTITION BY RANGE (C1)
    SUBPARTITION BY LIST (C2)
    PARTITION Part1 VALUES LESS THAN (1000)
    , PARTITION Part2 VALUES LESS THAN (2000)
    CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    When I execute
    SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    on a 10g database (10.2.0.2.0) on Solaris Sparc and on a 11.1.0.7 on Windows, it gives the correct DDL statement within some seconds.
    On the 11.2.0.3 database (Linux) it hangs forever.
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    ^CERROR:
    ORA-01013: user requested cancel of current operationWhy did you cencel this operation? Usually it takes time. If its taking more then it would be better to gather dictionary stats once.
    SQL>exec DBMS_STATS.GATHER_DICTIONARY_STATS;
    >
    This behavior only seems to occur in combination with local indexes and subpartitions.
    Anyone any idea?
    Thx, CarstenI didn't get any problem in 11.2.0.1 database:
    SQL> CREATE TABLE Test_tbl
      2  (
      3  C1 NUMBER(14),
      4  C2 NUMBER(14),
      5  C3 NUMBER(14)
      6  )
      7  PARTITION BY RANGE (C1)
      8  SUBPARTITION BY LIST (C2)
      9  (
    10  PARTITION Part1 VALUES LESS THAN (1000)
    11  , PARTITION Part2 VALUES LESS THAN (2000)
    12  );
    Table created.
    SQL>
    SQL> CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    Index created.
    SQL>
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    DBMS_METADATA.GET_DDL('INDEX','TEST_IDX')
      CREATE INDEX "SYS"."TEST_IDX" ON "SYS"."TEST_TBL" ("C3")
      PCTFREE 10 INITRAEdited by: 909592 on Mar 22, 2012 9:01 PM

  • :new., lob columns and after insert ... for each row trigger

    I'm having this little problem with
    my update/insert triggers and lob columns.
    I have this little trigger:
    CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
    AFTER INSERT ON BLOB_DATA
    FOR EACH ROW
    BEGIN
    INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
    END;
    Which works except when the DATA column
    is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
    The one thing that is different for the lob columns is that the application updating
    the data is using a bind statement with returning, like:
    INSERT INTO BLOB_DATA
    VALUES(:ID,EMPTY_BLOB())
    RETURNING DATA INTO :DATA;
    COMMIT;
    Thanks for any help

    I'm having this little problem with
    my update/insert triggers and lob columns.
    I have this little trigger:
    CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
    AFTER INSERT ON BLOB_DATA
    FOR EACH ROW
    BEGIN
    INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
    END;
    Which works except when the DATA column
    is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
    The one thing that is different for the lob columns is that the application updating
    the data is using a bind statement with returning, like:
    INSERT INTO BLOB_DATA
    VALUES(:ID,EMPTY_BLOB())
    RETURNING DATA INTO :DATA;
    COMMIT;
    Thanks for any help

  • How to save and retrieve an excel file as an object into lob column?

    Hi ,
    I need to save and retrieve the whole excel file with 3 or more sheets as an object into the lob column of table.
    For example:
    t_docments
    (doc_id number,
    excel_data clob
    All excel files need to be saved to excel_data column.
    What should I do?
    Thanks

    Did you check the asktom thread posted by Jens?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:232814159006
    There's example of varies file types.Yes, I did try some examples.
    Those work for .doc/.pdf/.jpg files, BUT NOT for excel file.
    The following error happened when retrieving excel file(retrieving .doc/.pdf are OK)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 375
    ORA-06512: at "SYS.UTL_FILE", line 990

  • ASSM and table with LOB column

    I have a tablespace created with ASSM option. I've heard about that tables with LOB columns can't take the advantage of ASSM.
    I made a test : create a table T with BLOB column in a ASSM tablespace. I succeeded!
    Now I have some questions:
    1. Since the segments of table T can't use ASSM to manage its blocks, what's the actrual approach? The traditional freelists??
    2. Will there be some bad impacts on the usage of the tablespace if table T becomes larger and larger and is used frequently?
    Thanks in advance.

    Can you explain what you mean by #1 because I believe it is incorrect and it does not make sense in my personal opinion. You can create a table in an ASSM tablespace that has a LOB column from 9iR2 on I believe (could be wrong). LOBs don't follow the traditional PCTFREE/PCTUSED scenario. They allocate data in what are called "chunks" that you can define at the time you create the table. In fact I think the new SECUREFILE LOBs actually require ASSM tablespaces.
    HTH!

  • Subpartition templates and DBMS_Metadata.Get_DDL

    Does anyone know of a way to get DBMS_Metadata.Get_DDL to specify a subpartition template clause instead of spitting out a specification for every subpartition? I'm finding a 6,000 line create table statement to be a little unwieldy ...
    This is 10.2.0.4

    Does anyone know of a way to get DBMS_Metadata.Get_DDL to specify a subpartition template clause instead of spitting out a specification for every subpartition? I'm finding a 6,000 line create table statement to be a little unwieldy ...
    This is 10.2.0.4

  • Stange error when using dbms_metadata.get_ddl in PL/SQL procedure

    Basic info:
    Oracle 10.2.0.4.0 on linux.
    I'm trying to extract ddl of indexes that I drop and recreate frequently during monthly loads and store it in a table.
    This statement works on the command line:
    insert into saved_indexes
    select index_name,dbms_metadata.get_ddl('INDEX',index_name,owner_name)
    from sys.all_indexes
    where owner = owner_name
    and table_name = table_name;
    commit;
    The table 'saved_indexes' is a two column table with a varchar2(40) and a CLOB.
    When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.
    PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2) IS
    v_errorcode number(8);
    v_errortext varchar2(1000);
    v_start_time date;
    BEGIN
    insert into saved_indexes
    select index_name,dbms_metadata.get_ddl('INDEX',index_name,v_owner)
    from sys.all_indexes
    where owner = v_owner
    and table_name = v_table;
    commit;
    EXCEPTION
    WHEN others THEN
    v_errorcode := sqlcode;
    v_errortext := substr(sqlerrm, 1, 1000);
    dbms_output.put_line(v_errortext || ' ' || v_errorcode);
    END;
    Alternatively I have tried it this way:
    PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2 ) IS
    v_errorcode number(8);
    v_errortext varchar2(1000);
    v_index_ddl CLOB;
    BEGIN
    for x in (select index_name
    from sys.all_indexes
    where owner = v_owner
    and table_name = v_table)
    loop
    select dbms_metadata.get_ddl('INDEX',x.index_name,v_owner) into v_index_ddl from dual;
    insert into saved_indexes
    values(v_table,v_index_ddl);
    end loop;
    commit;
    EXCEPTION
    WHEN others THEN
    v_errorcode := sqlcode;
    v_errortext := substr(sqlerrm, 1, 1000);
    dbms_output.put_line(v_errortext || ' ' || v_errorcode);
    END;
    Always with the same result. I have poured over the documentation on this and have not found anything. All objects are in the same schema, so there is not an issues with invokers rights, or privileges.
    Any suggestions would be helpful...

    qwe11126 wrote:
    When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.There is nothing wrong with SP. Post a snippet of SQL*Plus code showing how you call SP along with errors.
    SY.

  • DBMS_METADATA.GET_DDL inside the pl/sql procedure

    We have a requirement to drop certain materialized view and need to recreate based on certain condition inside the
    pl/sql procedure.i am using the dbms_metadata to get the Mv ddls.
    var1 := 'SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW,'MV_NAME','OWNER')'|| 'from dual' || ';' ;
    dbms_output.put_line(var1);
    But i am unable to get the create ddl syntax in var1.
    Can anyone help me on this

    Hi Deepu,
    you are not helping us too much. You information are coming drop by drop.
    Anyway, I don't have a materialized view but I have tried with a table.
    Here is my test and output (what I expect you too show us too):
    First test using normal SELECT FROM DUAL:
    SET LONG 2000000
    SET HEAD OFF
    SET ECHO ON
    SELECT DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS') FROM DUAL;
    Output:
    SQL>
    SQL> SELECT DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS') FROM DUAL;
      CREATE TABLE "SYS"."ALERT_QT"
       (    "Q_NAME" VARCHAR2(30),
            "MSGID" RAW(16),
            "CORRID" VARCHAR2(128),
            "PRIORITY" NUMBER,
            "STATE" NUMBER,
            "DELAY" TIMESTAMP (6),
            "EXPIRATION" NUMBER,
            "TIME_MANAGER_INFO" TIMESTAMP (6),
            "LOCAL_ORDER_NO" NUMBER,
            "CHAIN_NO" NUMBER,
            "CSCN" NUMBER,
            "DSCN" NUMBER,
            "ENQ_TIME" TIMESTAMP (6),
            "ENQ_UID" VARCHAR2(30),
            "ENQ_TID" VARCHAR2(30),
            "DEQ_TIME" TIMESTAMP (6),
            "DEQ_UID" VARCHAR2(30),
            "DEQ_TID" VARCHAR2(30),
            "RETRY_COUNT" NUMBER,
            "EXCEPTION_QSCHEMA" VARCHAR2(30),
            "EXCEPTION_QUEUE" VARCHAR2(30),
            "STEP_NO" NUMBER,
            "RECIPIENT_KEY" NUMBER,
            "DEQUEUE_MSGID" RAW(16),
            "SENDER_NAME" VARCHAR2(30),
            "SENDER_ADDRESS" VARCHAR2(1024),
            "SENDER_PROTOCOL" NUMBER,
            "USER_DATA" "SYS"."ALERT_TYPE" ,
            "USER_PROP" "SYS"."ANYDATA" ,
             PRIMARY KEY ("MSGID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSAUX"  ENABLE
       ) USAGE QUEUE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGIN
    G
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSAUX"
    OPAQUE TYPE "USER_PROP" STORE AS LOB (
      ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      CACHE
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT))
    {code}
    Now with the procedure storing in CLOB variable
    {code:sql}
    SET SERVEROUTPUT ON SIZE UNLIMITED
    SET LIN 5000
    SET LONG 20000000
    SET ECHO ON
    DECLARE
       l_clob         CLOB;
    BEGIN
       l_clob := DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS');
       DBMS_OUTPUT.put_line (l_clob);
    END;
    Output:
    SQL>
    SQL> DECLARE
      2     l_clob         CLOB;
      3  BEGIN
      4     l_clob := DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS');
      5     DBMS_OUTPUT.put_line (l_clob);
      6  END;
      7  /
      CREATE TABLE "SYS"."ALERT_QT"
       (    "Q_NAME" VARCHAR2(30),
            "MSGID" RAW(16),
            "CORRID" VARCHAR2(128),
            "PRIORITY" NUMBER,
            "STATE" NUMBER,
            "DELAY" TIMESTAMP (6),
            "EXPIRATION" NUMBER,
            "TIME_MANAGER_INFO" TIMESTAMP (6),
            "LOCAL_ORDER_NO" NUMBER,
            "CHAIN_NO" NUMBER,
            "CSCN" NUMBER,
            "DSCN" NUMBER,
            "ENQ_TIME" TIMESTAMP (6),
            "ENQ_UID" VARCHAR2(30),
            "ENQ_TID" VARCHAR2(30),
            "DEQ_TIME" TIMESTAMP (6),
            "DEQ_UID" VARCHAR2(30),
            "DEQ_TID" VARCHAR2(30),
            "RETRY_COUNT" NUMBER,
            "EXCEPTION_QSCHEMA" VARCHAR2(30),
            "EXCEPTION_QUEUE" VARCHAR2(30),
            "STEP_NO" NUMBER,
            "RECIPIENT_KEY" NUMBER,
            "DEQUEUE_MSGID" RAW(16),
            "SENDER_NAME" VARCHAR2(30),
            "SENDER_ADDRESS" VARCHAR2(1024),
            "SENDER_PROTOCOL" NUMBER,
            "USER_DATA" "SYS"."ALERT_TYPE" ,
            "USER_PROP" "SYS"."ANYDATA" ,
             PRIMARY KEY ("MSGID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSAUX"  ENABLE
       ) USAGE QUEUE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSAUX"
    OPAQUE TYPE "USER_PROP" STORE AS LOB (
      ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      CACHE
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT))
    {code}
    It should be nice if you could post your tests too if they are not working.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • DBMS_METADATA.GET_DDL - output trucating

    Hi,
    I am generating Database Package Scripts using the following.
    =====================================================
    set pagesize 0
    set long 90000
    set feedback off;
    column DDL format a80 WORD_WRAPPED
    spool FMONTUSER_PACKAGE.sql
    select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
    where owner='FMONTUSER' and
    object_type in('PACKAGE');
    spool off;
    ============================================
    This is the last PROCEDURE of Last PAKCGE in FMONTUSER_PACKAGE.sql
    =============================================
    PROCEDURE insert_loan_year_end_data(argloan_id IN LOAN.LOAN_ID%TYPE,
    arg_temp_prio_end_row IN TEMP_PRIOR_YEAR_END%ROWTYPE)
    IS
    v_as_of_dt LOAN_YEAR_END_DATA.ASOFDATE%TYPE;
    BEGIN
    -- Insert the record into original loan table
    DBMS_OUTPUT.put_line ('before insert LOAN_YEAR_END_DATA');
    v_as_of_dt := arg_temp_prio_end_row.AS_OF_DATE;
    INSERT INTO LOAN_YEAR_END_DATA     VALUES(LOAN_YEAR_END_DATA_SEQ.NEXTVAL,argloan_id,
    arg_temp_
    prio_end_row.BEGINNING_PRINCIPAL_BAL,arg_temp_prio_end_row.YTD_PRINCIPAL_PAID,
    =============================================
    I am getting trucated some lines in this procedure.
    I increased 'set long 90000' to 'set long 100000'
    Still I am getting truncated output.
    Please help me to solve this.
    regards,
    Mathew

    Hi,
    This script I am using.
    =======================================
    set pagesize 0
    --set long 90000
    set long 2000000000
    set feedback off;
    column DDL format a80 WORD_WRAPPED
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',false);
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', false);
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', false );
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', false );
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', false );
    spool FMONTUSER_PACKAGE.sql
    REM -------------------------------------------------------------------------------------------------------
    REM FMONTUSER_PACKAGE.sql
    REM PACKAGE.sql
    select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
    where owner='FMONTUSER' and
    object_type in('PACKAGE');
    spool off;
    regards
    Mathew

  • Dbms_metadata.get_ddl output format is not runable.

    Hi,
    I am using dbms_metadata.get_ddl to extract the objects. But the output returned is not runable.
    In output lines are broken so it makes unable to run that code.
    Ex. If I run this for all the synonyms like this.
    set pagesize 0
    set long 90000
    set feedback off
    set echo off
    spool /tmp/FixSyn.out
    select
    DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1')
    from
    dba_objects u
    where
    object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
    spool off;
    Output from this is coming like this.
    CREATE OR REPLACE SYNONYM "ADMINSRV_D1"."ASSTATEAPPORVALTYPE222" FOR "ADMINSRV
    _D1"."ASSTATEAPPORVALTYPE";
    CREATE OR REPLACE SYNONYM "ABC"."ASSTATEAPPORVALTYPE3" FOR "ADMINSRV_D
    1"."ASSTATEAPPORVALTYPE";
    This is broken in multiple lines so not possible to run this.
    Please provide any solution to fix this output.
    Thanks a lot,
    Amit.

    How about using word_wrapped
    set pagesize 0
    set long 90000
    set lines 131
    column txt format a121 word_wrapped
    set feedback off
    set echo off
    spool /tmp/FixSyn.out
    select
    DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1') txt
    from
    dba_objects u
    where
    object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
    spool off;
    For help on Column and default attributes.
    SQL> help column
    You can also check asktom replies.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:30802454515375
    Regards,
    Sabdar Syed.

  • Getting table script using dbms_metadata.get_ddl, but with clob field

    So, Oracle 11g R2..
    I'm using dbms_metadata.get_ddl to get table scripts and it's working fine..
    now, I have a table with clob field, and it's not working... I got an 'missing right parenthesis (ora-0907)' error...
    I could paste a script that I got, but I don't think it makes any sense..
    does anybody have some experience on using this package on clob tables?
    tnx

    this is script that I got... it's long, and it looks like it's not good
    CREATE TABLE "COMMON"."TEST_AAA2"
       (    "ID" NUMBER(10,0),
        "TEKST" VARCHAR2(200 CHAR),
        "UPDATESTAMP" DATE,
        "OBJEKAT" CLOB,
         CONSTRAINT "TEST_PART_PK2" PRIMARY KEY ("ID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USERS"
      ALTER INDEX "COMMON"."TEST_PART_PK2"  UNUSABLE ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS  LOGGING
      STORAGE(
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
      NOCACHE LOGGING
      STORAGE(
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
      PARTITION BY RANGE ("UPDATESTAMP")
    (PARTITION "P_201012"  VALUES LESS THAN (TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201101"  VALUES LESS THAN (TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201102"  VALUES LESS THAN (TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_ARCHIVE"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201103"  VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201104"  VALUES LESS THAN (TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_ARCHIVE"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201105"  VALUES LESS THAN (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201106"  VALUES LESS THAN (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_ARCHIVE"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_201107"  VALUES LESS THAN (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
    PARTITION "P_MAXVALUE"  VALUES LESS THAN (MAXVALUE)
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "COMMON_DATA"
    LOB ("OBJEKAT") STORE AS BASICFILE (
      TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
      NOCACHE LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS )

  • Using DBMS_METADATA.GET_DDL get error: ORA-00907: missing right parenthesis

    Hi,
    I'm trying to extract schema DDL from a database (10.2.0.4.0 - 64bit Enterprise Edition on Solaris 10). I run the query below and get an ORA-00907: missing right parenthesis error.
    SELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN ('TABLE_PARTITION','INDEX_PARTITION','LOB');
    This is the output when running the above in sqlplus worksheet
    select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects where object_type not in ('TABLE_PARTITION','INDEX_PARTITION','LOB')
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    removing the where clause gives the following:
    select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    Any pointers would be gratefully received. I know I could get the DDL out using exp/imp but I want to understand why I'm getting the missing parenthesis error.
    cheers,
    Ewan

    SELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN You don't need an alias here. Get rid of " AS object_type" and it should work.

  • Spool Command with dbms_metadata.GET_DDL function

    Hi All,
    My requirement is before applying a patch on the Database Schema, I need to take a backup of the db objects DDL script, so that incase if I want to rollback I can use it. what I am trying to use is the dbms_metadata.GET_DDL function to get the DDL script and with the help of spool command store that in a text file.
    The problem I am encountering is the whole script runs without an error but whne I check the spool file for certain big packages the DDL script is not fully exported. The below is the script that I make use of to generate the DDL script.
    set heading off
    set feedback off
    set echo off
    set term off
    set newpage none
    set space 0
    set trimout on
    set TRIMSPOOL ON
    column c1 format a4000
    set long 99999
    set lines 1000
    exec DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', true);
    spool c:\Rollback.sql
    select dbms_metadata.GET_DDL('FUNCTION',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'FUNCTION'
    and object_name in ('FN_CALCMASTERDATA_AGE','FUNC_ASSIGNBENEFITSNONFLEX','FUNC_CHECKNEWEMPLOYEE');
    select dbms_metadata.GET_DDL('PACKAGE_SPEC',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'PACKAGE'
    and object_name in('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST');
    select dbms_metadata.GET_DDL('PACKAGE_BODY',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'PACKAGE'
    and object_name in ('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST','PKGT_FLEX_INITIALIZATION','PKGT_EMP');
    spool off
    Note: Database Oracle 10 g,
    Client Machine Windows XP from where the script is ran.
    Is there any limitation in amount of data that can be spooled? or is there is any better way to accomplish this task, please help.
    Thanks
    Saami

    set long longer ;-)
    set long 1000000 longchunksize 1000000 linesize 32000 pagesize 0

Maybe you are looking for

  • How to fix Ipad3 disk

    The Ipad disk seem to have been corrupted during upgrade. Is there any way to fix it? I have tried accessing ipad using ssh tools but the ssh_rd_rev04b.jar tool does not support ipad 3. Below log Ipad 2013-12-06 22:51:32.012 [1604:a7c]: restore libra

  • How to make collapsible pages in a Swing Panel?

    Hi All, I have a JPanel in swing where I want elements which can be collapsed and expanded like in igoogle. These when expanded, can contains inside them subcomponents which can be labels, textfields, lists or trees!! Once collapsed, only the overall

  • 100% thread pool/CPU usage prevent MII Applications from working

    Hello to all, our MII Applications were running on MII 11.5 (windowsserver 2003, with IIS) without any problems. We migrated these MII Applications  to SAP xMII Version 12.0 SP8, SAP NW 7.00 SP20, Java HotSpot(TM) 64-Bit Server VM (build 1.4.2_22-rev

  • Unable to login to Oracle E-Business Suite R12 on Windows 2003

    Hi, I have recently installed EBS R12 on WIN 2003 that finished successfully. I can launch the login page - http://prora.com.au:8000/OA_HTML/AppsLogin I entered user/passwd as SYSADMIN/sysadmin but it didn't allow me to get inside. It doesn't display

  • Keyboard Issue in Leopard for Powerbook G4

    Since a fresh Leopard install, I have been having the following problems: the caps lock and num lock keys do not light up anymore, and the keyboard stops responding intermittently. The only fix I have found is to restart the computer. I have read abo