View Single Post
  #11 (permalink)  
Old 05-12-09, 11:56
chuck_forbes chuck_forbes is offline
Registered User
 
Join Date: Dec 2003
Posts: 1,072
Y'know, if you're on version 10g or later, you could use dbms_utility.format_call_stack. It will give you the current call stack information, without having to design a STACK_PG on your own.

The code would look something like:

Code:
create trigger table1_bt
before delete
on table1
for each row
  my_name varchar2(30) := 'TABLE1_BT';
  call_stack VARCHAR2(2000);
begin

  -- this looks to see if there is a second occurrence of this trigger
  --  in the call stack. If it is, the round trip is occurring and you should
  --  abort. Assumes that your TRIGGER names aren't similar enough that
  --  an INSTR test would be positive for both TRIGGER names. For example,
  --  the following 2 names are too similar: TABLE_BT and TABLE_BT2, while
  --  these would be ok: TABLE_BT and TABLE2_BT. Using a stack would 
  --  get you around this potential mistake, but, this stack already exists for
  --  you to search through.

  if instr(dbms_utility.format_call_stack, my_name, 1, 2) > 0 then
    return;
  end if;

  delete 
  from table2
  where some_field = :OLD.some_field;


  
end table1_bt;
Go ahead & write the contents of dbms_utility.format_call_stack to DBMS_OUTPUT so that you can see what it contains.

--=Chuck
Reply With Quote