Re: Get the table name in a trigger

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: 1998/08/26
Message-ID: <6s1f1s$g5s$1_at_pascal.a2000.nl>#1/1


>The dynamic SQL package (dbms_sql ) allows for the construction of any
>query at runtime.

Still, one needs to find out the table to which the currently running trigger is part of. I doubt that it can be done. Maybe userenv(..) has some parameter that can help you out.

If you are asking about database triggers, then you might use SQL*Plus to define the trigger in the first place. Then you can write a generic script like

    define TableName=&1
    create or replace trigger &TableName.BU       ...
    begin

      ...
      my_proc( '&TableName' )

    end;

You than execute this SQL script for every table that needs the trigger, having the table name as a parameter. Not exactly what you're lokking for, I know.

Just to give you a complete example, I have suffixed BU (before update) to the trigger name. Note that I used &TableName. (so: a dot after the word TableName). This will tell SQL*Plus that the variablename has ended, and that BU is not part of the variabele name.

By the way: please, don't crosspost to so many groups. It is not very clear if you're asking about database triggers, forms triggers, report triggers or whatever other trigger might exist in Oracle and Oracle tools.

Arjan.

>> Is there a way to get the name of the table that a trigger is defined on
>> from within the trigger code at run time?
Received on Wed Aug 26 1998 - 00:00:00 CEST

Original text of this message