[RESOLVED] dbms_metadata.get_ddl() issues

Hi all,
I'm having a bit of an issue using the dbms_metadata package. I've never used it so possibly I'm unaware of something basic.
I'm getting diferent results in my production and dev servers, both of which have this configuration:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
I am trying to replicate the DDL for one particular schema and so tried the following:
SQL> select dbms_metadata.get_ddl('TABLE',u.table_name)
  2  from user_tables u
  3  where rownum = 1;
ERROR:
ORA-06502: PL/SQL: numeric or value error
LPX-00210: expected '<' instead of 'n'
ORA-06512: at "SYS.UTL_XML", line 0
ORA-06512: at "SYS.DBMS_METADATA_INT", line 3698
ORA-06512: at "SYS.DBMS_METADATA_INT", line 4553
ORA-06512: at "SYS.DBMS_METADATA", line 458
ORA-06512: at "SYS.DBMS_METADATA", line 615
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1I tried again with hard-coding a table name and got these very scary results:
SQL> select dbms_metadata.get_ddl('TABLE','CAMPAIGN_LOOKUP','XMLUSER') FROM DUAL;
ERROR:
ORA-06502: PL/SQL: numeric or value error
ORA-31605: the following was returned from LpxXSLResetAllVars in routine
kuxslResetParams:
LPX-1: NULL pointer
ORA-06512: at "SYS.UTL_XML", line 0
ORA-06512: at "SYS.DBMS_METADATA_INT", line 3722
ORA-06512: at "SYS.DBMS_METADATA_INT", line 4553
ORA-06512: at "SYS.DBMS_METADATA", line 458
ORA-06512: at "SYS.DBMS_METADATA", line 615
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1in the above, I am logging in as the XMLUSER user and so owns the table campaign_lookup.
Next I tried getting the DDL for another schema that while still logged in as xmluser.
I'm certain that I have access read/write from the tclient table but got these results:
possibly the dbms_metadata package requires you to be loged in as the schema owner though
the oracle documentation link gives me a 404 error at the moment so I can't check.
SQL> select dbms_metadata.get_ddl('TABLE','TCLIENT','TRAVEL') from dual;
ERROR:
ORA-31603: object "TCLIENT" of type TABLE not found in schema "TRAVEL"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 628
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1So now I log into production:
SQL> select dbms_metadata.get_ddl('TABLE',u.table_name)
  2      from user_tables u
  3      where rownum = 1;
DBMS_METADATA.GET_DDL('TABLE',
  CREATE TABLE "XMLUSER"."CAMPAIGN_LOOKUP"
   (    "SCHEME_ID" VARCHAR2(30),
        "S
etc...but still can't extract DDL for another schema.
my main issue is, I can't log into production (or our implementation environment) as the schema
I want to extract due to big nasty DBAs locking it all down. however I can in dev, but get the above errors.
thoughts anyone?

Hi,
For your table not existing error it could be
1) Table not existing
or
2) Nonprivileged users can see the metadata of only their own objects.
SYS and users with SELECT_CATALOG_ROLE can see all objects
For other problem, there is a bug reported for your version, can search in metalink for workaround
Regards

Similar Messages

  • DBMS_METADATA.get_ddl issues

    When you run, select dbms_metadata.get_ddl('USER', 'scott') FROM DUAL; gives following error...
    ORA-31603: object "scott" of type USER not found in schema "SYSTEM"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 2805
    ORA-06512: at "SYS.DBMS_METADATA", line 4333
    ORA-06512: at line 1
    But this works...
    select dbms_metadata.get_ddl('USER', UPPER('scott')) FROM DUAL ;
    This gives result..
    DBMS_METADATA.GET_DDL('USER',U
    CREATE USER "SCOTT" IDENTIFIED BY VALUES 'F894844C34402B67'
    DEFAULT TABLESPACE "USERS"
    TEMPORARY TABLESPACE "TEMP"
    PASSWORD EXPIRE
    ACCOUNT LOCK
    I think the supplied object_name is case-sensitive. but why is it so.

    SQL> create user new_user identified by pwd;
    User created.
    SQL> select dbms_metadata.get_ddl('USER','NEW_USER') from dual;
    DBMS_METADATA.GET_DDL('USER','NEW_USER')
       CREATE USER "NEW_USER" IDENTIFIED BY VALUES 'D1ADB54B2BC01B82'
          TEMPORA
    SQL> select dbms_metadata.get_ddl('USER','new_user') from dual;
    ERROR:
    ORA-31603: object "new_user" of type USER not found in schema "SYSADM"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 653
    ORA-06512: at "SYS.DBMS_METADATA", line 1260
    ORA-06512: at line 1
    no rows selected
    SQL> create user "new_user" identified by pwd;
    User created.
    SQL> select dbms_metadata.get_ddl('USER','new_user') from dual;
    DBMS_METADATA.GET_DDL('USER','NEW_USER')
       CREATE USER "new_user" IDENTIFIED BY VALUES 'D1ADB54B2BC01B82'
          TEMPORAnew_user and "new_user" are two differents users.
    Nicolas.

  • Performance issue when trying to execute DBMS_METADATA.GET_DDL of a table

    Hello.
    I have a database with lots of partitioned tables and indexes and when I try to get the DDL of a partitioned table the query runs for hours and does not end.
    I tried do gather data dictionary statistics but it had no impact on performance.
    Can anybody help me find what's causing this performance problem?
    Information about the enviorment:
    Oracle version:
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    DDL query:
    select dbms_metadata.get_ddl('TABLE', 'TABLE1') from dual;
    On the "Top Activity" of the Database Control console, this is the query that's running:
    SELECT /*+all_rows*/ SYS_XMLGEN(VALUE(KU$), XMLFORMAT.createFormat2('TABLE_T', '7')), KU$.OBJ_NUM
    FROM SYS.KU$_PHTABLE_VIEW KU$
    WHERE NOT (BITAND (KU$.PROPERTY,8192)=8192) AND NOT BITAND(KU$.SCHEMA_OBJ.FLAGS,128)!=0 AND KU$.SCHEMA_OBJ.NAME=:NAME1 AND KU$.SCHEMA_OBJ.OWNER_NAME=:SCHEMA2;
    Edited by: Krulikowski on Jan 11, 2013 10:44 AM

    |*563 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 564 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*565 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 566 | VIEW | | 1 | 86 | | 4 (25)| 00:00:01 |
    | 567 | SORT ORDER BY | | 1 | 64 | | 4 (25)| 00:00:01 |
    | 568 | NESTED LOOPS | | 1 | 64 | | 3 (0)| 00:00:01 |
    | 569 | ID TABLE ACCESS BY INDEX ROW | SUBPARTCOL$ | 1 | 15 | | 2 (0)| 00:00:01 |
    |*570 | INDEX RANGE SCAN | I_SUBPARTCOL$ | 1 | | | 1 (0)| 00:00:01 |
    |*571 | TABLE ACCESS CLUSTER | COL$ | 1 | 49 | | 1 (0)| 00:00:01 |
    |*572 | INDEX UNIQUE SCAN | I_OBJ# | 1 | | | 0 (0)| 00:00:01 |
    | 573 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*574 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 575 | TABLE ACCESS CLUSTER | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*576 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 577 | ROWID TABLE ACCESS BY INDEX | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*578 | INDEX UNIQUE SCAN | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 579 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*580 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 581 | NESTED LOOPS | | 1 | 120 | | 5 (0)| 00:00:01 |
    | 582 | X ROWID TABLE ACCESS BY INDE | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*583 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 584 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*585 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 586 | R TABLE ACCESS CLUSTE | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*587 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 588 | DEX ROWID TABLE ACCESS BY IN | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*589 | INDEX UNIQUE SCAN | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 590 | TER TABLE ACCESS CLUS | TS$ | 1 | 18 | | 1 (0)| 00:00:01 |
    |*591 | N INDEX UNIQUE SCA | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 592 | STER TABLE ACCESS CLU | TS$ | 1 | 8 | | 1 (0)| 00:00:01 |
    |*593 | AN INDEX UNIQUE SC | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 594 | USTER TABLE ACCESS CL | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*595 | CAN INDEX UNIQUE S | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 596 | LUSTER TABLE ACCESS C | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*597 | SCAN INDEX UNIQUE | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 598 | BY INDEX ROWID TABLE ACCESS | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*599 | SCAN INDEX UNIQUE | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 600 | NESTED LOOPS | | 1 | 447 | | 900 (1)| 00:00:04 |
    |*601 | HASH JOIN | | 1 | 425 | | 899 (1)| 00:00:04 |
    | 602 | NESTED LOOPS | | 1 | 120 | | 5 (0)| 00:00:01 |
    | 603 | BY INDEX ROWID TABLE ACCESS | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*604 | SCAN INDEX RANGE | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 605 | CLUSTER TABLE ACCESS | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*606 | E SCAN INDEX UNIQU | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    |*607 | VIEW | INDPARTV$ | 33387 | 9944K| | 893 (1)| 00:00:04 |
    | 608 | R WINDOW BUFFE | | 33387 | 4336K| | 893 (1)| 00:00:04 |
    | 609 | S BY INDEX ROWID TABLE ACCES | INDPART$ | 33387 | 4336K| | 893 (1)| 00:00:04 |
    | 610 | SCAN INDEX FULL | I_INDPART_BOPART$ | 33387 | | | 103 (1)| 00:00:01 |
    | 611 | LUSTER TABLE ACCESS C | TS$ | 1 | 22 | | 1 (0)| 00:00:01 |
    |*612 | SCAN INDEX UNIQUE | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 613 | VIEW | | 19858 | 40M| | 1471 (1)| 00:00:07 |
    | 614 | SORT ORDER BY | | 19858 | 3956K| 4688K| 1471 (1)| 00:00:07 |
    |*615 | HASH JOIN | | 19858 | 3956K| | 698 (1)| 00:00:03 |
    | 616 | TABLE ACCESS FULL | LOB$ | 1547 | 24752 | | 461 (1)| 00:00:02 |
    |*617 | VIEW | LOBFRAGV$ | 19858 | 3645K| | 236 (1)| 00:00:01 |
    | 618 | WINDOW BUFFER | | 19858 | 1066K| | 236 (1)| 00:00:01 |
    | 619 | INDEX ROWID TABLE ACCESS BY | LOBFRAG$ | 19858 | 1066K| | 236 (1)| 00:00:01 |
    | 620 | INDEX FULL SCAN | I_LOBFRAG_PARENTOBJFRAG$ | 19858 | | | 61 (0)| 00:00:01 |
    | 621 | ER TABLE ACCESS CLUST | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*622 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 623 | NESTED LOOPS | | 1 | 120 | | 5 (0)| 00:00:01 |
    | 624 | NDEX ROWID TABLE ACCESS BY I | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*625 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 626 | TER TABLE ACCESS CLUS | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*627 | N INDEX UNIQUE SCA | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 628 | NESTED LOOPS | | 1 | 53 | | 5 (0)| 00:00:01 |
    | 629 | INDEX ROWID TABLE ACCESS BY | OBJ$ | 1 | 34 | | 4 (0)| 00:00:01 |
    |*630 | AN INDEX RANGE SC | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 631 | USTER TABLE ACCESS CL | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*632 | CAN INDEX UNIQUE S | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    |*633 | STER TABLE ACCESS CLU | COL$ | 1 | 49 | | 2 (0)| 00:00:01 |
    |*634 | AN INDEX UNIQUE SC | I_OBJ# | 1 | | | 1 (0)| 00:00:01 |
    | 635 | USTER TABLE ACCESS CL | TAB$ | 1 | 13 | | 2 (0)| 00:00:01 |
    |*636 | CAN INDEX UNIQUE S | I_OBJ# | 1 | | | 1 (0)| 00:00:01 |
    | 637 | Y INDEX ROWID TABLE ACCESS B | COLTYPE$ | 1 | 13 | | 2 (0)| 00:00:01 |
    |*638 | SCAN INDEX UNIQUE | I_COLTYPE2 | 1 | | | 1 (0)| 00:00:01 |
    | 639 | CLUSTER TABLE ACCESS | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*640 | SCAN INDEX UNIQUE | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 641 | BY INDEX ROWID TABLE ACCESS | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*642 | E SCAN INDEX UNIQU | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 643 | S CLUSTER TABLE ACCES | TS$ | 1 | 18 | | 1 (0)| 00:00:01 |
    |*644 | UE SCAN INDEX UNIQ | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 645 | SS CLUSTER TABLE ACCE | TS$ | 1 | 8 | | 1 (0)| 00:00:01 |
    |*646 | QUE SCAN INDEX UNI | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 647 | NESTED LOOPS | | 1 | 55 | | 3 (0)| 00:00:01 |
    | 648 | BY INDEX ROWID TABLE ACCESS | TABPART$ | 1 | 42 | | 2 (0)| 00:00:01 |
    |*649 | E SCAN INDEX UNIQU | I_TABPART_OBJ$ | 1 | | | 1 (0)| 00:00:01 |
    |*650 | CLUSTER TABLE ACCESS | TAB$ | 1 | 13 | | 1 (0)| 00:00:01 |
    |*651 | E SCAN INDEX UNIQU | I_OBJ# | 1 | | | 0 (0)| 00:00:01 |
    |*652 | FILTER | | | | | | |
    | 653 | MERGE JOIN | | 53239 | 2287K| | 1334 (2)| 00:00:06 |
    |*654 | VIEW | TABPARTV$ | 96857 | 3026K| | 872 (2)| 00:00:04 |
    | 655 | WINDOW SORT | | 96857 | 1513K| 2672K| 872 (2)| 00:00:04 |
    | 656 | ULL TABLE ACCESS F | TABPART$ | 96857 | 1513K| | 414 (2)| 00:00:02 |
    |*657 | SORT JOIN | | 273 | 3276 | | 462 (1)| 00:00:02 |
    | 658 | LL TABLE ACCESS FU | NTAB$ | 273 | 3276 | | 461 (1)| 00:00:02 |
    |*659 | FILTER | | | | | | |
    |*660 | FILTERING (UNIQUE) CONNECT BY WITH | | | | | | |
    | 661 | INDEX ROWID TABLE ACCESS BY | NTAB$ | 2 | 16 | | 2 (0)| 00:00:01 |
    |*662 | AN INDEX RANGE SC | I_NTAB1 | 2 | | | 1 (0)| 00:00:01 |
    | 663 | NESTED LOOPS | | 4 | 84 | | 4 (0)| 00:00:01 |
    | 664 | P CONNECT BY PUM | | | | | | |
    | 665 | LUSTER TABLE ACCESS C | NTAB$ | 2 | 16 | | 1 (0)| 00:00:01 |
    |*666 | SCAN INDEX UNIQUE | I_OBJ# | 1 | | | 0 (0)| 00:00:01 |
    |*667 | HASH JOIN | | 1 | 32 | | 5 (20)| 00:00:01 |
    |*668 | TER TABLE ACCESS CLUS | TAB$ | 1 | 13 | | 2 (0)| 00:00:01 |
    |*669 | N INDEX UNIQUE SCA | I_OBJ# | 1 | | | 1 (0)| 00:00:01 |
    |*670 | VIEW | TABPARTV$ | 214 | 4066 | | 2 (0)| 00:00:01 |
    | 671 | WINDOW BUFFER | | 214 | 2140 | | 2 (0)| 00:00:01 |
    |*672 | N INDEX RANGE SCA | I_TABPART_BOPART$ | 214 | 2140 | | 2 (0)| 00:00:01 |
    | 673 | VIEW | | 214 | 1304K| | 1555 (2)| 00:00:07 |
    | 674 | SORT ORDER BY | | 214 | 72546 | | 1555 (2)| 00:00:07 |
    |*675 | HASH JOIN | | 214 | 72546 | | 1554 (2)| 00:00:07 |
    | 676 | TABLE ACCESS FULL | USER$ | 184 | 3496 | | 4 (0)| 00:00:01 |
    | 677 | NESTED LOOPS | | | | | | |
    | 678 | NESTED LOOPS | | 214 | 68480 | | 1549 (2)| 00:00:07 |
    |*679 | HASH JOIN | | 214 | 46866 | | 907 (2)| 00:00:04 |
    |*680 | HASH JOIN | | 214 | 42800 | | 34 (3)| 00:00:01 |
    | 681 | TABLE ACCESS FULL | TS$ | 138 | 3036 | | 26 (0)| 00:00:01 |
    | 682 | NDEX ROWID TABLE ACCESS BY I | TABPART$ | 214 | 38092 | | 7 (0)| 00:00:01 |
    |*683 | INDEX RANGE SCAN | I_TABPART_BOPART$ | 214 | | | 2 (0)| 00:00:01 |
    | 684 | VIEW | TABPARTV$ | 96857 | 1797K| | 872 (2)| 00:00:04 |
    | 685 | WINDOW SORT | | 96857 | 1513K| 2672K| 872 (2)| 00:00:04 |
    | 686 | L TABLE ACCESS FUL | TABPART$ | 96857 | 1513K| | 414 (2)| 00:00:02 |
    |*687 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 2 (0)| 00:00:01 |
    | 688 | X ROWID TABLE ACCESS BY INDE | OBJ$ | 1 | 101 | | 3 (0)| 00:00:01 |
    | 689 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*690 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 691 | TABLE ACCESS CLUSTER | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*692 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 693 | R TABLE ACCESS CLUSTE | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*694 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 695 | DEX ROWID TABLE ACCESS BY IN | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*696 | INDEX UNIQUE SCAN | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 697 | TER TABLE ACCESS CLUS | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*698 | N INDEX UNIQUE SCA | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 699 | NESTED LOOPS | | 1 | 120 | | 5 (0)| 00:00:01 |
    | 700 | INDEX ROWID TABLE ACCESS BY | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*701 | N INDEX RANGE SCA | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 702 | STER TABLE ACCESS CLU | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*703 | AN INDEX UNIQUE SC | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 704 | USTER TABLE ACCESS CL | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*705 | CAN INDEX UNIQUE S | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 706 | Y INDEX ROWID TABLE ACCESS B | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*707 | SCAN INDEX UNIQUE | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 708 | CLUSTER TABLE ACCESS | TS$ | 1 | 18 | | 1 (0)| 00:00:01 |
    |*709 | SCAN INDEX UNIQUE | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 710 | CLUSTER TABLE ACCESS | TS$ | 1 | 8 | | 1 (0)| 00:00:01 |
    |*711 | E SCAN INDEX UNIQU | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 712 | S CLUSTER TABLE ACCES | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*713 | UE SCAN INDEX UNIQ | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 714 | SS CLUSTER TABLE ACCE | SEG$ | 1 | 70 | | 3 (0)| 00:00:01 |
    |*715 | QUE SCAN INDEX UNI | I_FILE#_BLOCK# | 1 | | | 2 (0)| 00:00:01 |
    | 716 | ESS BY INDEX ROWID TABLE ACC | DEFERRED_STG$ | 1 | 28 | | 2 (0)| 00:00:01 |
    |*717 | IQUE SCAN INDEX UN | I_DEFERRED_STG1 | 1 | | | 1 (0)| 00:00:01 |
    | 718 | S NESTED LOOP | | 1 | 421 | | 2864 (1)| 00:00:13 |
    | 719 | PS NESTED LOO | | 1 | 402 | | 2863 (1)| 00:00:13 |
    | 720 | N MERGE JOI | | 1 | 380 | | 2862 (1)| 00:00:13 |
    |*721 | VIEW | INDSUBPARTV$ | 203K| 54M| | 2857 (1)| 00:00:13 |
    | 722 | BUFFER WINDOW | | 203K| 13M| | 2857 (1)| 00:00:13 |
    | 723 | ACCESS BY INDEX ROWID TABLE | INDSUBPART$ | 203K| 13M| | 2857 (1)| 00:00:13 |
    | 724 | FULL SCAN INDEX | I_INDSUBPART_POBJSUBPART$ | 203K| | | 517 (1)| 00:00:03 |
    |*725 | N SORT JOI | | 1 | 101 | | 5 (20)| 00:00:01 |
    | 726 | CCESS BY INDEX ROWID TABLE A | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*727 | RANGE SCAN INDEX | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |
    | 728 | ESS CLUSTER TABLE ACC | TS$ | 1 | 22 | | 1 (0)| 00:00:01 |
    |*729 | IQUE SCAN INDEX UN | I_TS# | 1 | | | 0 (0)| 00:00:01 |
    | 730 | SS CLUSTER TABLE ACCE | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*731 | QUE SCAN INDEX UNI | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 732 | VIEW | | 3220 | 6653K| | 252 (2)| 00:00:02 |
    | 733 | SORT ORDER BY | | 3220 | 679K| | 252 (2)| 00:00:02 |
    |*734 | HASH JOIN | | 3220 | 679K| | 251 (1)| 00:00:02 |
    | 735 | NESTED LOOPS | | | | | | |
    | 736 | NESTED LOOPS | | 12 | 336 | | 14 (0)| 00:00:01 |
    | 737 | FULL TABLE ACCESS | LOBCOMPPART$ | 12 | 144 | | 2 (0)| 00:00:01 |
    |*738 | SCAN INDEX UNIQUE | I_LOB2 | 1 | | | 0 (0)| 00:00:01 |
    | 739 | BY INDEX ROWID TABLE ACCESS | LOB$ | 1 | 16 | | 1 (0)| 00:00:01 |
    |*740 | VIEW | LOBFRAGV$ | 19858 | 3645K| | 236 (1)| 00:00:01 |
    | 741 | WINDOW BUFFER | | 19858 | 1066K| | 236 (1)| 00:00:01 |
    | 742 | BY INDEX ROWID TABLE ACCESS | LOBFRAG$ | 19858 | 1066K| | 236 (1)| 00:00:01 |
    | 743 | SCAN INDEX FULL | I_LOBFRAG_PARENTOBJFRAG$ | 19858 | | | 61 (0)| 00:00:01 |
    | 744 | Y INDEX ROWID TABLE ACCESS B | TABSUBPART$ | 1 | 111 | | 3 (0)| 00:00:01 |
    |*745 | SCAN INDEX UNIQUE | I_TABSUBPART$_OBJ$ | 1 | | | 2 (0)| 00:00:01 |
    | 746 | VIEW | | 418K| 2477M| | 38130 (1)| 00:02:41 |
    | 747 | SORT ORDER BY | | 418K| 177M| 192M| 38130 (1)| 00:02:41 |
    |*748 | HASH JOIN | | 418K| 177M| | 3590 (3)| 00:00:16 |
    | 749 | TABLE ACCESS FULL | USER$ | 184 | 3496 | | 4 (0)| 00:00:01 |
    |*750 | HASH JOIN | | 418K| 170M| | 3582 (2)| 00:00:16 |
    | 751 | L TABLE ACCESS FUL | TS$ | 138 | 3036 | | 26 (0)| 00:00:01 |
    |*752 | HASH JOIN | | 418K| 161M| | 3552 (2)| 00:00:15 |
    | 753 | VIEW | TABSUBPARTV$ | 30 | 9120 | | 4 (0)| 00:00:01 |
    | 754 | WINDOW BUFFER | | 30 | 3750 | | 4 (0)| 00:00:01 |
    | 755 | BY INDEX ROWID TABLE ACCESS | TABSUBPART$ | 30 | 3750 | | 4 (0)| 00:00:01 |
    |*756 | SCAN INDEX RANGE | I_TABSUBPART_POBJSUBPART$ | 30 | | | 3 (0)| 00:00:01 |
    | 757 | LL TABLE ACCESS FU | OBJ$ | 825K| 79M| | 3539 (2)| 00:00:15 |
    | 758 | NDEX ROWID TABLE ACCESS BY I | LOB$ | 1 | 10 | | 2 (0)| 00:00:01 |
    |*759 | N INDEX UNIQUE SCA | I_LOB2 | 1 | | | 1 (0)| 00:00:01 |
    | 760 | STER TABLE ACCESS CLU | USER$ | 1 | 19 | | 1 (0)| 00:00:01 |
    |*761 | AN INDEX UNIQUE SC | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    | 762 | NESTED LOOPS | | 1 | 120 | | 5 (0)| 00:00:01 |
    | 763 | INDEX ROWID TABLE ACCESS BY | OBJ$ | 1 | 101 | | 4 (0)| 00:00:01 |
    |*764 | AN INDEX RANGE SC | I_OBJ1 | 1 | | | 3 (0)| 00:00:01 |

  • 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 performance

    Hi
    My application need to run on a schema and get all the DDL of the schema objects.
    This action is very heavy on the server and I get 100% on the server CPU.
    my code look something like this:
    SELECT
    D.OBJECT_NAME,
    D.OBJECT_TYPE,
    TRIM(SYS.DBMS_METADATA.GET_DDL(REPLACE(REPLACE(OBJECT_TYPE,'DATABASE LINK','DB_LINK'),' ','_'),OBJECT_NAME,USER)) AS OBJECTCREATIONSCRIPT
    FROM SYS.USER_OBJECTS D
    INNER JOIN TEMPOBJECTSLIST OL
    ON OL.DBOBJECT_NAME = D.OBJECT_NAME
    AND OL.DBOBJECT_TYPE = D.OBJECT_TYPE
    WHERE OBJECT_TYPE IN('TABLE', 'VIEW', 'FUNCTION', 'PROCEDURE', 'PACKAGE', 'PACKAGE BODY', 'SEQUENCE', 'TYPE', 'SYNONYM', 'MATERIALIZED VIEW', 'DATABASE LINK', 'TYPE BODY', 'TRIGGER')
    Is ther any way to do this faster?
    I was thinking on some ways but I do not know how to implement them:
    1. working on paralel CPU - The action acording to Enterprise Manager is taking 100% of 1 of 4 CPUs.
    2. Add some indexes or run statistics on some where in the database.
    3. some other options...
    thanks

    Thanks, But I can't use an incremental table for this action becouse of some business logical restrictions of my application.
    the application need to do the same action as GET_DDL for all the schema objects like one schema snapshot.
    I have a new idea of solving this issue, perhaps someone could help me who to implement it (if it possible):
    DMBS_METATDATA package has a procedure GET_XML this procedure is match faster than GET_DDL.
    Is ther any way to convert the XML result of GET_XML to a DDL script?
    Edited by: rronen on 00:06 01/09/2010
    Edited by: rronen on 00:06 01/09/2010

  • DBMS_METADATA.GET_DDL doesn't include function parameters

    Sometimes, when I call DBMS_METADATA.GET_DDL to get the DDL statement for a function (which we always do to ensure we're starting from the source that's actually in production), the returned text doesn't include the parameters. Other times, it does, and I'm not able to see any pattern.
    I was going to just make a function and show the output, but that did show the parameters. Then I tried calling GET_DDL while logged in as SYS as SYSDBA on my development database, and I still did not get the parameters, so I don't think it's a permissions issue.
    Does anyone have any idea what's going on here?

    It's really difficult to show you exactly what I'm doing when I can't consistently reproduce the problem, as I described.
    But here, I'll try.
    declare
         the_ddl clob;
    begin
         the_ddl := dbms_metadata.get_ddl('FUNCTION', '*****', '*****');
         dbms_output.enable(null);
         dbms_output.put_line(the_ddl);
    end;
    /Sometimes, it produces output like this:
    CREATE OR REPLACE FUNCTION "*****"."*****" (
         ***** in varchar2,
         ***** in number,
    ) return *****
    ...And other times, it produces output like this:
    CREATE OR REPLACE FUNCTION "*****"."*****" return *****
    ...I am not able to determine any consistent reason for this. In our production database, I can log in as myself and get the parameters for a specific function, but another user (that our automated process uses) doesn't see the parameters. In my development database, I log in as myself and I do not see the parameters, but I still don't see them when I log in as SYS AS SYSDBA.
    For what it's worth, if I recreate the function on my development database, then subsequent calls do show the parameters.

  • Problem with dbms_metadata.get_ddl

    When I issue following statement:
    Select DBMS_METADATA.GET_DDL ('TABLE', 'ACQ_OPSC')
    From Dual;
    I get these errors.
    Error:
    ORA-06502: PL/SQL: Numeric or Value Error.
    LPX-00210: Expected '<' instead of 'n'
    ORA-06512: at "sys.utl_xml", line 0
    bunch more ORA-06512 errors.
    Oracle version: Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
    What is the problem?

    Please check dbmssml.sql and initmeta.sql under $ORACLE_HOME/rdbms/admin if you have changed your oracle home after installation to patch - A common practice though not blessed by oracle. These files will have value of original ORACLE_HOME hard coded in them. You have to update them manually with the new ORACLE_HOME. Once you update it run them on each database that is using this ORACLE_HOME.

  • Setting DBMS_METADATA.GET_DDL Output for Materialized Views

    Hi all.
    My Oracle version is 10g.
    I'm extracting the DDL of all the objects from database using the DBMS_METADATA package. I'm using SET_TRANSFORM_PARAM to configure the output because I need a simple sql code, without information about tablespaces, storage and segment attributes. Everything works fine except when I'm working with mviews object types. I can't remove the information about tablespace, storage or segment attributes for materialized views.
    I would like to know if there's a related issue about it. Or there's something missing in my code?
    I tried to specify the object type as another parameter on DBMS_METADATA.SET_TRANSFORM_PARAM but don't work too.
    The only transform parameter that works fine with Materialized Views is the SQLTERMINATOR.
    See how I have done:
    declare
    vDDL clob;
    begin
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR',TRUE);
    select dbms_metadata.get_ddl ('MATERIALIZED_VIEW', 'MV_STO020', 'HIS117_CHECK') into vDDL FROM DUAL;
    dbms_output.put_line (vDDL);
    end;
    and how the output is:
    CREATE MATERIALIZED VIEW "HIS117_CHECK"."MV_STO020"
    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 "TS_HIS117"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS SELECT
    STO020_MOVEMENT_LOG_ID STO020_MOVEMENT_LOG_ID
    , STO020_QUANTITY STO020_QUANTITY
    , STO020_DATE STO020_DATE
    , STO020_BEFORE_BALANCE STO020_BEFORE_BALANCE
    , STO011_PRODUCT_MOVEMENT_ID STO011_PRODUCT_MOVEMENT_ID
    , ADM082_PRODUCT_ID ADM082_PRODUCT_ID
    , ADM089_PRODUCT_PRESENTATION_ID ADM089_PRODUCT_PRESENTATION_ID
    , STO010_MOVEMENT_TYPE_ID STO010_MOVEMENT_TYPE_ID
    , STO001_STOCK_ID STO001_STOCK_ID
    , STO001_TARGET_STOCK_ID STO001_TARGET_STOCK_ID
    , STO003_PRODUCT_LOT_ID STO003_PRODUCT_LOT_ID
    , SYS010_USER_ID SYS010_USER_ID
    , EIR001_MPI EIR001_MPI
    , ADM056_MEDICAL_ATTENTION_ID ADM056_MEDICAL_ATTENTION_ID
    , ADM094_USE_UNIT_ID ADM094_USE_UNIT_ID
    FROM
    STO020_MOVEMENT_LOG;
    Thank you in advanced!
    Edited by: lucporto on 28/08/2012 07:26

    Right. I found this way but I consider this just a quick fix, because I think there should be a better way to do this.
    create table t_clob (c_long);
    declare
    p clob;
    begin
    delete from t_clob;
    execute immediate 'insert into t_clob (select to_lob(query) from dba_mviews where owner = :1 and mview_name = :2)'
    USING 'HIS117', 'MV_STO020';
    select 'CREATE MATERIALIZED VIEW MV_STO020' || chr(10) ||
    'REFRESH ON DEMAND' || chr(10) || 'AS' || CHR(10) || mv.c_long
    into p
    from t_clob mv;
    dbms_output.put_line(p);
    end;
    Thanks all.

  • Error while using DBMS_METADATA.GET_DDL package.

    Hi all,
    I want script of DDL of all tables in Database not in particular schema,
    As I am using below query
    SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
    FROM ALL_TABLES u
    WHERE u.nested='NO'
    AND (u.iot_type is null or u.iot_type='IOT')
    but it gives error as below.
    ORA-31603: object "ICOL$" of type TABLE not found in schema "SCOTT"
    It should give DDL of all tables, also I am not having DBA Privs.
    Please help me.
    Thanks & Regards
    Rajiv.

    It could be helpful if you have a look into [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1016867]documentation.
    Security Model
    The object views of the Oracle metadata model implement security as follows:
    Nonprivileged users can see the metadata of only their own objects.
    SYS and users with SELECT_CATALOG_ROLE can see all objects.
    Nonprivileged users can also retrieve public synonyms, system privileges granted to them, and object privileges granted to them or by them to others. This also includes privileges granted to PUBLIC.
    If callers request objects they are not privileged to retrieve, no exception is raised; the object is simply not retrieved.
    If nonprivileged users are granted some form of access to an object in someone else's schema, they will be able to retrieve the grant specification through the Metadata API, but not the object's actual metadata.
    In stored procedures, functions, and definers-rights packages, roles (such as SELECT_CATALOG_ROLE) are disabled. Therefore, such a PL/SQL program can only fetch metadata for objects in its own schema. If you want to write a PL/SQL program that fetches metadata for objects in a different schema (based on the invoker's possession of SELECT_CATALOG_ROLE), you must make the program invokers-rights.
    Best regards
    Maxim

  • Calling DBMS_METADATA.GET_DDL on scheduler jobs owned by SYS

    Hi!
    While I can generally retrieve the DDL for scheduler jobs using the PROCOBJ type, this doesn't seem to work for scheduler jobs owned by SYS.
    Does anybody happen to have a workaround for this?
    SELECT user FROM dual
    USER
    SYS
    1 row selected
    select * from v$version
    BANNER                                                         
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production        
    5 rows selected
    SELECT DBMS_METADATA.GET_DDL('PROCOBJ' ,'MGMT_CONFIG_JOB', 'ORACLE_OCM') DDL FROM dual
    DDL
    BEGIN dbms_scheduler.create_job( ...
    1 row selected
    SELECT DBMS_METADATA.GET_DDL('PROCOBJ' ,'AUTO_SPACE_ADVISOR_JOB', 'SYS') DDL FROM dual
    ORA-31603: object "AUTO_SPACE_ADVISOR_JOB" of type PROCOBJ not found in schema "SYS"
    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 1Cheers,
    Marcus

    I guess I need SELECT_CATALOG_ROLE role
    http://www.orafaq.com/node/807
    SYS and users with SELECT_CATALOG_ROLE can see all objects.

  • Execute immediate on DBMS_METADATA.GET_DDL with error of ORA-01031: insufficient privileges

    I want to mirror a schema to a existing schema by creating DDL and recreate on the other schema with same name.
    I wrote the code below:
    create or replace
    PROCEDURE                                    SCHEMA_A."MAI__DWHMIRROR"
    AS
    v_sqlstatement CLOB:='bos';
    str varchar2(3999);
    BEGIN
      select
        replace(
          replace(replace(
          replace(DBMS_METADATA.GET_DDL('TABLE','XXXX','SCHEMA_A'),'(CLOB)',''),';','')
        ,'SCHEMA_A'
        ,'SCHEMA_B'
      into v_sqlstatement
      from dual;
      select  CAST(v_sqlstatement AS VARCHAR2(3999)) into str from dual;
      execute immediate ''||str;
    END;
    And Executing this block with below code:
    set serveroutput on
    begin
    SCHEMA_A.MAI__DWHMIRROR;
    end;
    But still getting the following error code:
    Error report:
    ORA-01031: insufficient privileges
    ORA-06512: at "SCHEMA_A.MAI__DWHMIRROR", line 47
    ORA-06512: at line 2
    01031. 00000 -  "insufficient privileges"
    *Cause:    An attempt was made to change the current username or password
               without the appropriate privilege. This error also occurs if
               attempting to install a database without the necessary operating
               system privileges.
               When Trusted Oracle is configure in DBMS MAC, this error may occur
               if the user was granted the necessary privilege at a higher label
               than the current login.
    *Action:   Ask the database administrator to perform the operation or grant
               the required privileges.
               For Trusted Oracle users getting this error although granted the
               the appropriate privilege at a higher label, ask the database
               administrator to regrant the privilege at the appropriate label.

    user5199319 wrote:
    USER has DBA Role
    when all  else fails Read The Fine Manual
    DBMS_METADATA

  • Dbms_metadata.get_ddl including comments.

    Hey all,
    Is there a way to use the dbms_metadata package to fetch the DDL of a package/function/procedure without removing the comments? For instance if you are using SQL Developer and right click a function and then click edit. The DDL for the function will appear along with the comments. This is what I would like to see.
    Any ideas?
    Cheers,
    Tyson Jouglet
    Edited by: Tyson Jouglet on Aug 27, 2009 2:29 PM

    Is there a way to use the dbms_metadata package to fetch the DDL of a package/function/procedure without removing the comments? Why do you think that the comments are removed?
    SQL>  CREATE OR REPLACE PROCEDURE p
    /* first comment*/
    AS
    -- some comments
    BEGIN
         /* some other comments*/
         NULL;
    END p;
    Procedure created.
    SQL>  SELECT dbms_metadata.get_ddl (
                    'PROCEDURE',
                    'P',
                    USER
               ) ddl
      FROM DUAL
    DDL                                                                            
      CREATE OR REPLACE PROCEDURE "MICHAEL"."P"                                    
    /* first comment*/                                                             
    AS                                                                             
    -- some comments                                                               
    BEGIN                                                                          
         /* some other comments*/                                                      
         NULL;                                                                         
    END p;                                                                         
    1 row selected.

  • 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/]

  • DBMS_METADATA.GET_DDL - Required permissions in absense of SELECT_CATALOG_R

    Hi,
    In our production database SELECT_CATALOG_ROLE cannot be given to any normal user because of Security policy.
    I am normal user and I would like to use DBMS_METADATA.GET_DDL to get the DDL's of all the objects for creation of physical data model using tool.
    In absense of SELECT_CATALOG_ROLE, are there any alternate roles/grants present which can be given to the normal user so that he/she can use GET_DDL for any object in the database?
    Many Thanks in Advance!

    Might not be exact match but Note 312883.1 talks about this.
    Another way could be by create script/procedure to generate the DDL (like we use to do in 9i) and call it in place of DBMS_METADATA. This would require granting of SELECT privs on few dictionary objects. Check below article.
    http://www.dba-oracle.com/oracle_tips_dbms_metadata.htm

Maybe you are looking for

  • Pc music library quest

    When I got my creative jukebox zen extra 40gb for xmas, I loaded a couple hundred songs on it to check it out. Well, I have now put all my mp3 files on my hd and organized them. I want to clear the music library from the media source orgranizer and s

  • Encapsulation Error in Crystal Reports using Web Service Connection

    Hi Experts, I'd like to request help in investigating an issue we are currently having in Crystal Reports.  Basically, the solution design is: -Web Service is Used as connection -Dynamic Hyperlink value is used to access another Crystal Report Issue:

  • [new] mudmagic 1.0.4

    The second of my first batch of packages: mudmagic. A MUD(Multi User Dungeon, text based online roleplaying games) client with mapping and notes support. I'm not quite sure about the substitution of those automake-scripts, but it works for me.. Here'

  • My mac keeps slowing down or miscuing when i'm trying to record in garageband

    Any tips on speeding up my macbook when i'm recording, I've disabled my wi-fi and blue tooth and nothing else is running, but still has lag for some reason when i'm recording which is a real pain when i'm trying to record in real time.

  • REUSE_ALV_GRID_DISPLAY function

    Hello, with 'REUSE_ALV_GRID_DISPLAY'function, once displayed, I need to show in a label, a field from the List, is there a way to do this. I did try and see if a user command occurs , when I select a line, but there was not one generated. Thanks