Thread: Trigger

Trigger

From
Carolyn Lu Wong
Date:
I'm using V6.5.3.

I'm trying to create transaction logs for particular table, so I need to
write trigger on insert/delete/update on each row. Are there any
examples/documents that can help me with this?

In the "Interaction with the Trigger Manager" from the online document,
it states that it's for V7.1 or later. Because I'm working on earlier
version, do I need to modify my code if the database is upgraded to
later versions?

I'm writing the C program in under my home directory. How can I set up
the environment so that my program compiles?

Thanks in advance for any helps and directions.


Re: Trigger

From
Tom Lane
Date:
Carolyn Lu Wong <carolyn@kss.net.au> writes:
> In the "Interaction with the Trigger Manager" from the online document,
> it states that it's for V7.1 or later. Because I'm working on earlier
> version, do I need to modify my code if the database is upgraded to
> later versions?

The trigger interface for 7.0 is the same as in 6.5, so you can rely
on the online document for now.

7.1 will have a different trigger interface (but the document hasn't
been updated yet).  The key difference is that the TriggerData structure
will be passed as a parameter rather than being pointed to by a global
variable.  You can minimize the number of changes you will need to make
by not referring to CurrentTriggerData all over the place --- instead,
copy it into a local variable at the start of your trigger function.

> I'm writing the C program in under my home directory. How can I set up
> the environment so that my program compiles?

Easiest way is to point -I at the src/include tree, I'm afraid.  There
are some examples of C triggers in the contrib/ area, take a look at
their makefiles.
        regards, tom lane