FW: Infromix question
Posted in 1997
Am passing the following inquiry along for a co-worker...
***********************************
I would like to know if it is possible to create an insert trigger for =
the following table.=20
CREATE TABLE dlp_in_ebp (
ebp_id integer NOT NULL,
dlp_id integer NOT NULL,
sequence smallint NOT NULL,
client char(25) NOT NULL,
PRIMARY KEY (client, ebp_id, dlp_id, sequence),=20
FOREIGN KEY (client)
REFERENCES client_list,=20
FOREIGN KEY (dlp_id)
REFERENCES dlp,=20
FOREIGN KEY (ebp_id)
REFERENCES ebp
);
This trigger would search the table for an occurrence of an ebp_id, =
dlp_id, and a client with the following select. The reference to =
"inserted" in the select is a from an insert referencing clause in the =
trigger.
select count(*)
from dlp_in_ebp
where inserted.dlp_id =3D dlp_in_ebp.dlp_id
and inserted.ebp_id =3D dlp_in_ebp.ebp_id
and inserted.client =3D dlp_in_ebp.client
If the count that is returned is 0, I would like to insert a 1 in the =
sequence column with the ebp_id, dlp_id, and client columns being the =
same as the above select. If the returned value is greater than 0, I =
would like to added 1 to that value and insert that new value in the =
sequence column with the ebp_id, dlp_id, and client columns being the =
same as the above select.=20
My experience in trying to added this trigger has ended with the =
following Informix error, 747 "Table or column matches object referenced =
in triggering statement. This error is returned when a triggered SQL =
statement acts on the triggering table, or when both statements are =
updates and the column being updated in the triggered action is the same =
as the column being updated by the triggering statement." My question is =
this. Can the results that I desire be accomplished with a =
trigger/stored procedure combination? If so what would be the syntax of =
the trigger and stored procedure?
********************
Thanks for any help you can pass our way.
Matt Sauter
CSC CIS, Englewood, CO