Subject | Re: [IBO] favourite record |
---|---|
Author | Lucas Franzen |
Post date | 2002-09-03T09:01:27Z |
bamberger_monjaude schrieb:
FOR MYTABLE BEFORE UPDATE POSITION 0
AS BEGIN
IF ( NEW.EMAIL = '1' AND OLD.EMAIL = '0' ) THEN
BEGIN
/* Reset the old favourite record */
UPDATE MYTABLE SET EMAIL = '0' WHERE EMAIL = '1';
END
END
Of course you can also write an insert trigger that will handle
inserting a new record with the favourite flag set.
Luc.
>CREATE TRIGGER BU_MYTABLE
> Hi!
> I have a table witch saves e-mail accounts and I want to give the
> user the opinion to select a favourite account, so I've created a
> boolean column and I want to secure that only one record could have
> the value=true. I would like to realize this with a trigger on the
> IB, but my SQL-knowlegde is to bad.
FOR MYTABLE BEFORE UPDATE POSITION 0
AS BEGIN
IF ( NEW.EMAIL = '1' AND OLD.EMAIL = '0' ) THEN
BEGIN
/* Reset the old favourite record */
UPDATE MYTABLE SET EMAIL = '0' WHERE EMAIL = '1';
END
END
Of course you can also write an insert trigger that will handle
inserting a new record with the favourite flag set.
Luc.