Text of Oracle Trigger

It seems I’ve come to rely on Quest Toad. Now that I’ve returned to working with Oracle on a regular basis, I have to remind myself how to do things from SQLPLUS when I don’t have TOAD available.

Today I needed to examine the text of a trigger, but I couldn’t remember the view to obtain it from. Here’s the code to spool it to a text file:

-- eliminate row count message
set feedback off
-- eliminate headings from showing
set heading off
-- suppress output
set termout off
-- don't show sql in result set
set echo off
-- keep text body from wrapping
set linesize 1000
-- eliminate trailing blanks
set trimspool on
spool /tmp/trigger.sql
select 'CREATE OR REPLACE ' from dual;
select text from user_source
where name = 'TRIGGERNAME';
select '/' from DUAL;
spool off
set feedback on
set heading on
set termout on
set linesize 100
set echo on

Leave a Reply