Insert Trigger Question
Posted in 1998
I'm trying to create a trigger for a table insert. This trigger would call
a stored procedure which should calculate the value to be stored in the
column which makes up the primary key. The stored procedure accepts as an
input parameter the table name (in quoted text.) The SP returns an integer
value (which should be used as the key). The SP tests ok. For example,
from DBACCESS, executing the command:
execute procedure combo_key ("t_fred1");
returns a numeric value 1051 (which is what I want).
The table (t_fred1) I'm attempting to trigger has columns:
t_serial integer (this is the primary key)
t_name character 20
I wrote the trigger to look like:
CREATE TRIGGER trigger_fred1 insert ON t_fred1
referencing new as new_rec
for each row(execute procedure combo_key("t_fred1") into t_serial);
Attempting to create the trigger I get the error message "Invalid use of
column reference in trigger body"
If I leave off the "into t_serial" I can create the trigger but when insert
takes place, t_serial doesn't get updated.