Skip to Main Content

SQL & PL/SQL

Announcement

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

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

dbms_metadata.get_ddl with triggers and execute immediate

Evie-OracleFeb 14 2018 — edited Feb 16 2018

Hi

I'd like to "export" my objects' DDL from one schema and run it in another schema.

I'd like to generate the DDL statements separately, not in a single script (or CLOB), so that when I run them in the new schema I can keep track of the execution of each of them separately and capture potential errors.

Using dbms_metadata.get_ddl I am facing the following problem:

When it generates the DDL for triggers, it would return two statements per trigger (CREATE TRIGGER and ALTER TRIGGER ENABLE ).

In the target schema I'd use  execute immediate, and it would fail because it is no able to execute these two statements in this form:

  CREATE OR REPLACE EDITIONABLE TRIGGER "FTS_COV_SR_LOG_AUDIT"

     before insert or update on FTS_COV_SR_LOG    for each row

begin

    null ; -- contents is irrelevant...

end;

ALTER TRIGGER "FTS_COV_SR_LOG_AUDIT" ENABLE;

Is there a way to get dbms_metadata to return the trigger creation DDL not including the ALTER TRIGGER statement or basically not return more than one statement per object? So something that execute immediate would be able to execute

thanks in advance for hints!

This post has been answered by Paulzip on Feb 14 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2018
Added on Feb 14 2018
22 comments
5,254 views