Subject | Before Delete trigger |
---|---|
Author | yaedos2000 |
Post date | 2004-12-20T11:21:03Z |
Hi,
I've got two tables, TBL_MARKER and TBL_MTRNS, both of which contain
a field MARKID.
I have a procedure which deletes a row from TBL_MARKER (DELETE FROM
TBL_MARKER WHERE MARKID = SOME_VALUE). But this row can only be
deleted if MARKID from TBL_MARKER doesn't exist in TBL_MTRNS. If it
does then the delete cannot take place.
I'm developing a Before Delete trigger to test for this and to stop
the delete occuring if MARKID exists in the other table.
How would I check each row of TBL_MTRNS for a match? Could it be done
using a SELECT statement, ie. SELECT MARKID FROM TBL_MTRNS? And how
would I stop the delete from occur if there is a match?
CREATE TRIGGER BD_MARKER FOR TBL_MARKER
ACTIVE BEFORE DELETE POSITION 0
AS
BEGIN
END ^
Thanks
I've got two tables, TBL_MARKER and TBL_MTRNS, both of which contain
a field MARKID.
I have a procedure which deletes a row from TBL_MARKER (DELETE FROM
TBL_MARKER WHERE MARKID = SOME_VALUE). But this row can only be
deleted if MARKID from TBL_MARKER doesn't exist in TBL_MTRNS. If it
does then the delete cannot take place.
I'm developing a Before Delete trigger to test for this and to stop
the delete occuring if MARKID exists in the other table.
How would I check each row of TBL_MTRNS for a match? Could it be done
using a SELECT statement, ie. SELECT MARKID FROM TBL_MTRNS? And how
would I stop the delete from occur if there is a match?
CREATE TRIGGER BD_MARKER FOR TBL_MARKER
ACTIVE BEFORE DELETE POSITION 0
AS
BEGIN
END ^
Thanks