Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
Debug DDL trigger

Debug DDL trigger

2005-08-22       - By rjamya

Reply:     1     2     3     4     5     6     7     8     9     10     >>  

With all due respect, first of all get rid of the exception clause. This
thing alone has helped me find 99% of the issues where "this stupid trigger
doesn't fire" is the catch phrase. Once you see the error, rest is easy.

As a boundary condition, what error do you think you will get if my table
name is exactly (or more than) 27 characters long? Also I'd prefer to get
rid of the WHEN clause of the trigger and add that to the WHERE clause.

Raj

On 8/22/05, Herring Dave - dherri <Dave.Herring@(protected)> wrote:
>
>  Folks,
>
>  I'm having a rough time trying to figure out how to debug a DDL trigger.
> I'm on Oracle 9.2.0.4 <http://9.2.0.4>, under Tru64 5.1. I've written a
> trigger whose purpose is to make a backup copy of a table in one schema into
> another, before the table gets dropped. The problem is, as far as I can
> tell, the trigger is never fired. I've validated that the trigger exists and
> is enabled, but can't get any further. Is there a way to trace how triggers
> get chosen to be fired by Oracle?
>
>  Here's the trigger's text:
>
>  CREATE OR REPLACE TRIGGER sys.cp_tab_before_drop_btg
>
> BEFORE drop ON dherri.SCHEMA
>
> WHEN ( ora_dict_obj_type = 'TABLE'
>
> AND ( ora_dict_obj_name LIKE 'SCORE\_ACCT\_TB\_%' ESCAPE '\'
>
> )
>
> )
>
> DECLARE
>
> PRAGMA AUTONOMOUS_TRANSACTION;
>
> v_datestamp DATE := sysdate;
>
> v_ddl_stmt VARCHAR2(4000);
>
> v_ora_error NUMBER;
>
> v_procedure_name VARCHAR2(30) := 'CP_TAB_BEFORE_DROP_BTG';
>
> v_procedure_owner VARCHAR2(30) := 'SYS';
>
> v_table_count PLS_INTEGER := 1;
>
>  BEGIN
>
> INSERT INTO dherri.aud_plsql_error_tb values ('SYS','Test: Before
> SELECT',1,sysdate);
>
> COMMIT;
>
>  /*
>
> * Validate the table to be dropped does exist.
>
> */
>
> SELECT COUNT(*) INTO v_table_count
>
> FROM dba_tables
>
> WHERE owner = ora_dict_obj_owner
>
> AND table_name = ora_dict_obj_name;
>
>  IF v_table_count > 0 THEN
>
> INSERT INTO dherri.aud_plsql_error_tb values ('SYS','Test: Within
> IF-TEST',v_table_count,sysdate);
>
> COMMIT;
>
>  v_ddl_stmt := 'CREATE TABLE dherri.'||ora_dict_obj_name||'_bkp PCTFREE 0
> AS SELECT * FROM dherri.'||ora_dict_obj_name||';';
>
> EXECUTE IMMEDIATE v_ddl_stmt;
>
> END IF;
>
>  EXCEPTION
>
> WHEN OTHERS THEN
>
> v_ora_error := ABS(SQLCODE);
>
> INSERT INTO dherri.aud_plsql_error_tb VALUES (v_procedure_owner,
> v_procedure_name, v_ora_error, sysdate);
>
> END;
>
> /
>
>  Dave
>
> -- ---- ---- ---- ---- ---- ---- ----
>
> Dave Herring, DBA
>
> Acxiom Corporation
>
> 3333 Finley
>
> Downers Grove, IL 60515
>
> wk: 630.944.4762
>
> <mailto:dherri@(protected) <dherri@(protected)>>
>
> -- ---- ---- ---- ---- ---- ---- ----
>
>  **************************************************************************
> The information contained in this communication is confidential, is
> intended only for the use of the recipient named above, and may be legally
> privileged.
>
> If the reader of this message is not the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited.
>
> If you have received this communication in error, please resend this
> communication to the sender and delete the original message or any copy
> of it from your computer system.
>
> Thank You.
> **************************************************************************
>
>


--
-- ---- ---- ---- ---- ---- --
select standard_disclaimer from company_requirements where category =
'MANDATORY';

With all due respect, first of all get rid of the exception clause.
This thing alone has helped me find 99% of the issues where &quot;this
stupid trigger doesn't fire&quot; is the catch phrase. Once you see the
error, rest is easy.<br>
<br>
As a boundary condition, what error do you think you will get if my
table name is exactly (or more than) 27 characters long? Also I'd
prefer to get rid of the WHEN clause of the trigger and add that to the
WHERE clause.<br>
<br>
Raj<br><br><div><span class="gmail_quote">On 8/22/05, <b class="gmail
_sendername">Herring Dave - dherri</b> &lt;<a href="mailto:Dave.Herring@(protected)
.com">Dave.Herring@(protected)</a>&gt; wrote:</span><blockquote class="gmail
_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0
.8ex; padding-left: 1ex;">











<div>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">Folks,</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">I'm having a rough time trying to figure out how to debug a
DDL trigger.&nbsp; I'm on Oracle <a href="http://9.2.0.4" target="_blank"
onclick="return top.js.OpenExtLink(window,event,this)">9.2.0.4</a>, under Tru64
5.1.&nbsp; I've written a trigger
whose purpose is to make a backup copy of a table in one schema into another,
before the table gets dropped. &nbsp;The problem is, as far as I can tell, the
trigger is never fired. &nbsp;I've validated that the trigger exists and is
enabled,
but can't get any further. &nbsp;Is there a way to trace how triggers get
chosen to
be fired by Oracle?</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">Here's the trigger's text:</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">CREATE OR REPLACE TRIGGER sys.cp_tab_before_drop_btg</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; BEFORE drop ON dherri.SCHEMA</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHEN (&nbsp;&nbsp;&nbsp; ora_dict_obj_type =
'TABLE'</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND (&nbsp
;&nbsp; ora_dict_obj_name LIKE
'SCORE\_ACCT\_TB\_%' ESCAPE '\'</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp; )</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</span></font><
/p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">DECLARE</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; PRAGMA AUTONOMOUS_TRANSACTION;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_datestamp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
; DATE := sysdate;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_ddl_stmt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; VARCHAR2(4000);</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_ora_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
; NUMBER;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_procedure_name&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR2(30) :=
'CP_TAB_BEFORE_DROP_BTG';</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_procedure_owner&nbsp;&nbsp;&nbsp; VARCHAR2(30) := 'SYS';</span
></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; v_table_count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PLS
_INTEGER := 1;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">BEGIN</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; INSERT INTO dherri.aud_plsql_error_tb values
('SYS','Test: Before SELECT',1,sysdate);</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; COMMIT;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">/*</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;* Validate the table to be dropped does exist.</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;*/</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; SELECT COUNT(*) INTO v_table_count</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp; FROM dba_tables</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp; WHERE owner = ora_dict_obj_owner</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND table_name = ora_dict_obj_name;</span><
/font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; IF v_table_count &gt; 0 THEN</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO dherri.aud_plsql_error_tb values
('SYS','Test: Within IF-TEST',v_table_count,sysdate);</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMIT;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_ddl_stmt := 'CREATE TABLE dherri.'||ora_dict
_obj_name||'_bkp
PCTFREE 0 AS SELECT * FROM dherri.'||ora_dict_obj_name||';';</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXECUTE IMMEDIATE v_ddl_stmt;</span></font></p
>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; END IF;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">EXCEPTION</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp; WHEN OTHERS THEN</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_ora_error := ABS(SQLCODE);</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO dherri.aud_plsql_error_tb VALUES
(v_procedure_owner, v_procedure_name, v_ora_error, sysdate);</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">END;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">/</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial
;">Dave</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">-- ---- ---- ---- ---- ---- ---- ----</span></font
></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">Dave Herring, DBA</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">Acxiom Corporation</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">3333 Finley</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">Downers Grove, IL 60515</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">wk: 630.944.4762</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">&lt;</span></font><font face="Arial"><span style=
"font-family: Arial;"><a href="mailto:dherri@(protected)" target="_blank" onclick
="return top.js.OpenExtLink(window,event,this)">
<font color="teal" size="2"><span style="font-size: 10pt; color: teal;">mailto
:dherri@(protected)</span></font></a></span></font><font color="teal" face="Arial
" size="2"><span style="font-size: 10pt; font-family: Arial; color: teal;">
&gt;</span></font></p>

<p><font color="teal" face="Arial" size="2"><span style="font-size: 10pt; font
-family: Arial; color: teal;">-- ---- ---- ---- ---- ---- ---- ----</span></font
></p>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;<
/span></font></p>

</div>

<pre>**************************************************************************
<br>The information contained in this communication is confidential, is<br
>intended only for the use of the recipient named above, and may be legally
<br>privileged.<br><br>If the reader of this message is not the intended
recipient, you are<br>hereby notified that any dissemination, distribution or
copying of this<br>communication is strictly prohibited.<br><br>If you have
received this communication in error, please resend this
<br>communication to the sender and delete the original message or any copy<br
>of it from your computer system.<br><br>Thank You.<br>*************************
*************************************************<br></pre>



</blockquote></div><br><br clear="all"><br>-- <br>-- ---- ---- ---- ---- ------
-<br>select standard_disclaimer from company_requirements where category =
'MANDATORY';<br>