Saturday, May 26, 2012

Script to List Trigger Code

This script will extract the code for a specific trigger in your database.
REM LOCATION:   Object Management\Trigger Reports
REM FUNCTION:   Extract Code for Trigger
REM TESTED ON:  10.2.0.3, 11.1.0.6
REM PLATFORM:   non-specific
REM REQUIRES:   dbms_metadata, dba_triggers
REM NOTE:       Wild card (%) for owner and trigger name allowed.
REM
REM
REM ******************** Oracle Administration ********************
UNDEF ENTER_OWNER_NAME
UNDEF ENTER_TRIGGER_NAME
SET long 1000000
SET verify off  feedback off lines 132 pages 58 echo off
COLUMN trigger_ddl format a100 wrap heading "Trigger|DDL|Code"

SELECT DBMS_METADATA.get_ddl ('TRIGGER', trigger_name, owner) trigger_ddl
  FROM dba_triggers
 WHERE owner LIKE '&&ENTER_OWNER_NAME'
   AND trigger_name LIKE '&&ENTER_TRIGGER_NAME';