Hello!
Corporate table, t1, should contain exact 1 row.
I strongly believe that there are cleaner versions
than the following combination of trigger and rule.
Thank you in advance for any improved version!
CNLIOU
--------
CREATE TABLE t1 (CorpId TEXT,CorpName TEXT);
CREATE FUNCTION f1() RETURNS OPAQUE AS '
DECLARE rc SMALLINT;
BEGIN SELECT COUNT(*) INTO rc FROM t1;
IF rc > 0 THEN RETURN NULL; END IF;
RETURN NEW;
END;' LANGUAGE 'plpgsql';
CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH
ROW EXECUTE PROCEDURE f1();
CREATE RULE rule1 AS ON DELETE TO t1 DO INSTEAD
NOTHING;
--------------------------------------------------------
You too can have your own email address from Eurosport.
http://www.eurosport.com