Syntax for checking DBMS_METADATA.GET_DDL('DB_LINK'')

i am using oracle 8i any suggestion in syntax here?
SQL> Select DBMS_METADATA.GET_DDL('DB_LINK',p140.ngco.com,'PPRUSR') FROM dual;
Select DBMS_METADATA.GET_DDL('DB_LINK',p140.ngco.com,'PPRUSR') FROM dual
ERROR at line 1:
ORA-00904: invalid column name
BANNER
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production

1. The DB_LINK name must be enclosed by quotes
2. DBMS_METADATA is not available on 8.1.7 Oracle version.
Nicolas.

Similar Messages

  • Why dbms_metadata.get_ddl can not work for db link?

    db: 10.2.4
    os: RH linux 5
    our problem is that we can not get ddl from dbms_metadata.get_ddl for database link, however the db link does exist here as below.
    SQL> select * from dba_db_links where owner='XXRPTH';
    OWNER DB_LINK USERNAME HOST CREATED
    XXR TO_DOPDB.XXR.COM TEST db_opdb 18-FEB-08
    XXR XXRPTH_OPDBC.XXR.COM TEST db_opdb 15-JUL-08
    XXR XXRPTH_BLIS.XXR.COM BLIS dbls 02-JUN-08
    SQL> select dbms_metadata.get_ddl('DB_LINK','XXRPTH_OPDBC.XXR.COM','XXR') from dual;
    ERROR:
    ORA-31603: object "XXRPTH_OPDBC.XXR.COM" of type DB_LINK not found in schema "XXR"
    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
    appreciate for any guides
    thanks

    I ran into this in a slightly different form, I can't remember all the rules and details, but to work around it I had to specify a fake name appendage in the db link creation in order to keep it from automatically appending the global domain.
    Something like
    create database link abcdef.remotealias connect to ... using 'remotealias'
    rather than
    create database link abcdef connect to... using 'remotealias'
    At least I think it was fake, I was flopping around trying things until I got it to work, and I wound up making it the same as the tnsnames alias. I think I decided I didn't have to, but left it as the lesser of two confusions, and was miffed that the creation scripts I had been using for years suddenly had to be fixed. Yeah, it was my own damned fault, but I still think the way this works is crazy. Now hopefully someone will explain this simply so I look foolish.

  • Dbms_metadata.GET_DDL for all procedures for a schema

    I am trying to capture all the procedure DDLs for schema CUSTOM
    I am using 11g on Linux.
    I run this command...
    SELECT dbms_metadata.GET_DDL('PROCEDURE',NULL,'CUSTOM') FROM DUAL;
    And get this error:
    ORA-31600: invalid input value NULL for parameter VALUE in function SET_FILTER
    ORA-06512: at "SYS.DBMS_METADATA", line 4018
    ORA-06512: at "SYS.DBMS_METADATA", line 5843
    ORA-06512: at line 1
    Thanks in advance.

    user13716252 wrote:
    I am trying to capture all the procedure DDLs for schema CUSTOM
    I am using 11g on Linux.
    I run this command...
    SELECT dbms_metadata.GET_DDL('PROCEDURE',NULL,'CUSTOM') FROM DUAL;
    And get this error:
    ORA-31600: invalid input value NULL for parameter VALUE in function SET_FILTER
    ORA-06512: at "SYS.DBMS_METADATA", line 4018
    ORA-06512: at "SYS.DBMS_METADATA", line 5843
    ORA-06512: at line 1
    Thanks in advance.specify actual procedure name; not NULL

  • CTAS using dbms_metadata.get_ddl for Partitioned table

    Hi,
    I would like to create a temporary table from a partitioned table using CTAS. I plan to use the following steps in a PL/SQL procedure:
    1. Use dbms_metadata.get_ddl to get the script
    2. Use raplace function to change the tablename to temptable
    3. execute the script to get the temp table created.
    SQL> create or replace procedure p1 as
    2 l_clob clob;
    3 str long;
    4 begin
    5 SELECT dbms_metadata.get_ddl('TABLE', 'FACT_TABLE','USER1') into l_clob FROM DUAL;
    6 dbms_output.put_line('CLOB Length:'||dbms_lob.getlength(l_clob));
    7 str:=dbms_lob.substr(l_clob,dbms_lob.getlength(l_clob),1);
    8 dbms_output.put_line('DDL:'||str);
    9 end;
    12 /
    Procedure created.
    SQL> exec p1;
    CLOB Length:73376
    DDL:
    PL/SQL procedure successfully completed.
    I cannot see the DDL at all. Please help.

    Thanks Adam. The following piece of code is supposed to do that. But, its failing because the dbms_lob.substr(l_clob,4000,4000*v_intIdx +1); is putting newline and therefore dbms_sql.parse
    is failing.
    Please advice.
    create table my_metadata(stmt_no number, ddl_stmt clob);
    CREATE OR REPLACE package USER1.genTempTable is
    procedure getDDL;
    procedure createTempTab;
    end;
    CREATE OR REPLACE package body USER1.genTempTable is
    procedure getDDL as
    Description: get a DDL from a partitioned table and change the table name
    Reference: Q: How Could I Format The Output From Dbms_metadata.Get_ddl Utility? [ID 394143.1]
    l_clob clob := empty_clob();
    str long;
    l_dummy varchar2(25);
    dbms_lob does not have any replace function; the following function is a trick to do that
    procedure lob_replace( p_lob in out clob, p_what in varchar2, p_with in varchar2 )as
    n number;
    begin
    n := dbms_lob.instr( p_lob, p_what );
    if ( nvl(n,0) > 0 )
    then
    dbms_lob.copy( p_lob,
    p_lob,
    dbms_lob.getlength(p_lob),
    n+length(p_with),
    n+length(p_what) );
    dbms_lob.write( p_lob, length(p_with), n, p_with );
    if ( length(p_what) > length(p_with) )
    then
    dbms_lob.trim( p_lob,
    dbms_lob.getlength(p_lob)-(length(p_what)-length(p_with)) );
    end if;
    end if;
    end lob_replace;
    begin
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
    DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
    DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
    execute immediate 'truncate table my_metadata';
    -- Get DDL
    SELECT dbms_metadata.get_ddl('TABLE', 'FACT','USER1') into l_clob FROM DUAL;
    -- Insert the DDL into the metadata table
    insert into my_metadata values(1,l_clob);
    commit;
    -- Change the table name into a temporary table
    select ddl_stmt into l_clob from my_metadata where stmt_no =1 for update;
    lob_replace(l_clob,'"FACT"','"FACT_T"');
    insert into my_metadata values(2,l_clob);
    commit;
    -- execute immediate l_clob; <---- Cannot be executed in 10.2.0.5; supported in 11gR2
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');
    end getDDL;
    Procedure to create temporary table
    procedure createTempTab as
    v_intCur pls_integer;
    v_intIdx pls_integer;
    v_intNumRows pls_integer;
    v_vcStmt dbms_sql.varchar2a;
    l_clob clob := empty_clob();
    l_str varchar2(4000);
    l_length number;
    l_loops number;
    begin
    select ddl_stmt into l_clob from my_metadata where stmt_no=2;
    l_length := dbms_lob.getlength(l_clob);
    l_loops := ceil(l_length/4000);
    for v_intIdx in 0..l_loops loop
    l_str:=dbms_lob.substr(l_clob,4000,4000*v_intIdx +1);
    l_str := replace(l_str,chr(10),'');
    l_str := replace(l_str,chr(13),'');
    l_str := replace(l_str,chr(9),'');
    v_vcStmt(v_intIdx) := l_str;
    end loop;
    for v_intIdx in 0..l_loops loop
    dbms_output.put_line(v_vcStmt(v_intIdx));
    end loop;
    v_intCur := dbms_sql.open_cursor;
    dbms_sql.parse(
    c => v_intCur,
    statement => v_vcStmt,
    lb => 0,
    --ub => v_intIdx,
    ub => l_loops,
    lfflg => true,
    language_flag => dbms_sql.native);
    v_intNumRows := dbms_sql.execute(v_intCur);
    dbms_sql.close_cursor(v_intCur);
    end createTempTab;
    end;
    /

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

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

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

  • Dbms_metadata.get_ddl returns text of table script but not the view

    Hi all
    I am using a DDL trigger like
    CREATE OR REPLACE TRIGGER SYS.log_ddl AFTER DDL
    ON DATABASE
    declare
    n_text varchar2(2000);
    begin
    if ora_sysevent='CREATE' and ora_dict_obj_type='VIEW' then
    select dbms_metadata.get_ddl
    (ora_dict_obj_type ,ora_dict_obj_name,ora_dict_obj_owner)
    into n_text from dual;
    elsif ora_sysevent='CREATE' and ora_dict_obj_type='TABLE' then
    select dbms_metadata.get_ddl
    (ora_dict_obj_type ,ora_dict_obj_name,ora_dict_obj_owner) into n_text from dual
    end if;
    end;
    on execution
    the first condition produces an error if the view does not already exists
    ORA-31603: object "TEST" of type VIEW not found in schema "SHAI"
    but the second condition of table creation executs successfuly and return the script of the table
    what can be the main theory behind this.

    I think some of the bug fixes were targeted for 9.2.0.5, but I can't tell you for certain.
    One of the things I really don't like about DBMS_METADATA is that it returns an error if a specified object does not exist. For example, I created a sql script that would accept a schema name as the input parameter and would generate all the ddl for the schema. If the schema did not have a particular object, for example a sequence, the call to DBMS_METADATA to generate the sequence ddl would return an error instead of returning nothing. I had error checking in the script, so this caused problems. (Oracle's response is that this is expected behaviour).
    This might be what is happening with your call.
    Dan

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

  • Using dbms_metadata.get_ddl to capture the alter table

    Hi there,
    I know you can capture table ddl using dbms_metadata.get_ddl. However, I want to capture all the changes after the table got created. If you created a table then add one or more columns. I just want to capture the change as the new columns added.
    Here's an example.
    Create table test (id number, name varchar2(20);
    then
    alter table test add (type varchar2(40);
    I want to capture the syntax "alter table test add (type varchar(40)". Is this possible?
    Thanks

    I dont belive you could easily use dbma_metadata to do this... but you can use a database or schema level trigger e.g. :
    create or replace trigger test.test_trigger
    AFTER ALTER
    ON DATABASE
    DECLARE
    sql_text ora_name_list_t;
    v_stmt VARCHAR2(2000);
    n number;
    BEGIN
    n := ora_sql_txt(sql_text);
    FOR i IN 1..n
    LOOP
    v_stmt := v_stmt || sql_text(i);
    END LOOP;
    INSERT INTO test.test_table2
    VALUES
    (v_stmt);
    END;
    This will capture all alter commands fired at the database... so you would then need to filter them using the System-Defined Event Attributes see
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#i1006211

  • 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

  • Use of DBMS_METADATA.GET_DDL with respect to triggers

    We are very pleased with DMBS_METADATA for punching DDLs in general, We use the following to create executable scripts for recreating any object in our databases.
    SELECT DBMS_METADATA.GET_DDL('OBJECT_TYPE', 'OBJECT_NAME', 'SAINADM' ) from dual;
    In most types of object, the DDL produced can be executed without errors, providing that the original target object was well founded. However, we have found that in the case of a triggers, the DDL produced does not function for the following reason:
    EXAMPLE
    -- This set of instructions is produced by a metascript too complicated to show here
    SPOOL TRIGGER_NAME.trg
    SELECT DBMS_METADATA.GET_DDL('TRIGGER', 'TRIGGER_NAME', 'SCHEMA_NAME' ) txt
    FROM DUAL;
    SPOOL OFF
    END OF EXAMPLE
    This will produce the following output, spooled to the file TRIGGER_NAME.trg
    OUTPUT
    -- we have anonymised our object names
    -- the syntax is what I would like you to focus on
    CREATE OR REPLACE TRIGGER "SCHEMA_NAME"."TRIGGER_NAME"
    BEFORE INSERT on SCHEMA_NAME.TABLE_NAME FOR EACH ROW
    BEGIN
    select SCHEMA_NAME.SEQUENCE_NAME.nextval
    into :new.colname
    from dual;
    END;
    ALTER TRIGGER SCHEMA_NAME"."TRIGGER_NAME" ENABLE
    _END OF OUTPUT_
    Note what has happened.
    1. The trigger DDL has been produced
    2. So has a the ALTER TRIGGER ... ENABLE
    3. BUT => between the trigger DDL and the alter trigger statement the is no slash (of course, because naturally DBMS_METADATA does not produce such characters). BUT this is problematic, because the combination of the Create trigger statement and the alter trigger statement, without a slash in between means that the spool file is atomically illegal. Because in real life we need a slash between the two staements.
    Why is this a problem for us?
    - Because we are about to introduce the automation of object changes between our "Development" "Integration" "Quality Assurance" and "Production" databases based on the execution of files produced by DBMS_METADATA.GET_DDL. For every other type of object, the file produced is well founded and executable DDL that will create the object. But in the case of triggers, the existence of the alter trigger statement renders the foregoing create trigger statement unexecutable.
    The use of DMBS_METADATA is more or less vanilla. That is to say, there appears to be no scope for instructing DBMS_METADATA to abstain form including the alter trigger statement
    SELECT DBMS_METADATA.GET_DDL('TRIGGER', 'TRIGGER_NAME', 'SCHEMA_NAME' ) txt
    Here are my questions
    1. How can we punch the DDL for triggers without bringing the alter trigger statement
    2. Alternatively, how can we automate the insertion of the slash character in between the CREATE TRIGGER and the ALTER TRIGGER in the original metascript that creates the example spool file.
    Thanks for your attention. Every response will be welcomed.
    Edited by: user10248070 on Mar 2, 2010 3:54 AM

    You can use
    dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE );See http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10577/d_metada.htm#BGBJBFGE.
    Example:
    SQL> set long 1000
    SQL> set heading off
    SQL> select * from v$version;
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> exec dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE );
    PL/SQL procedure successfully completed.
    SQL> SELECT DBMS_METADATA.GET_DDL('TRIGGER', 'UPDATE_JOB_HISTORY', 'HR' ) txt
      2  FROM DUAL;
      CREATE OR REPLACE TRIGGER "HR"."UPDATE_JOB_HISTORY"
      AFTER UPDATE OF job_id, department_id ON employees
      FOR EACH ROW
    BEGIN
      add_job_history(:old.employee_id, :old.hire_date, sysdate,
                      :old.job_id, :old.department_id);
    END;
    ALTER TRIGGER "HR"."UPDATE_JOB_HISTORY" ENABLE;Edited by: P. Forstmann on 2 mars 2010 13:48

  • 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

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

Maybe you are looking for

  • FILE_GET_NAME and FILE

    Hi Experts,       Can any one explain the use of Function moudule File_Get_name and the use of Transaction Code FILE.

  • How to save custom Producer Kits?

    Hello. I've been trying to save a complete custom mixed/edited producer kit with no succes. There's an article how to load, edit and save the patches, but I haven't been able to make the custom saved producer kits to appear in the library or even in

  • Problem to register database 9. in OID 10.1.2

    Hello, I try to register a database version 9.2 in my ldap OID 10.1.2 with utility dbca (for implementing user enterprise) , I have executed this operation for an 10.2 database without problem. I don't use wallet just password authentification. dbca

  • Passing Display Name to Portlet(report) as a parameter???

    Does anyone know if we can pass the Display Name for a report dynamically to the portlets? For now, I have had to create one page for each report(portlet) by Overwriting the report display option and using specific Query Option for each portlet. Pref

  • Administering AQ JMS objects in JNDI

    I had used several JMS providers before like MQ and Tibco but I'm new to Oracle AQ. I'm trying to write a JMS client program which lookups a connection factory and a destination from a JNDI context, and then create a session and publish JMS messages.