At 2:11 PM +0200 1/10/07, Nicolai Tufar wrote:
Hi all,

We plan to port a small problem from MS SQL to Ingres. Almost every
table has one ON UPDATE trigger that updates username column with
relevant information. We try to port it to Ingres and alas, there are
no BEFORE rules in Ingres :(

We tried to do it with AFTER:

        CREATE TABLE test (id INT, username VARCHAR(10));

        CREATE PROCEDURE test_upd_proc(id INT) AS
        BEGIN
                UPDATE test SET username=CURRNET_USER WHERE id=:id;
        END;

        CREATE RULE test_rule_upd  AFTER UPDATE ON test
        FOR EACH ROW
        EXECUTE PROCEDURE  test_upd_proc(id = NEW.id);

For this particular case you can add
... WHERE username <> CURRENT_USER
to the rule and prevent the rule-firing loop.

Ingres 2006 Release 2 will have BEFORE rules, I think.
If not in Release 2, then the next one after.

Karl
_______________________________________________
Users mailing list
Users@lists.ingres.com
http://lists.ingres.com/mailman/listinfo/users

Reply via email to