Some prickly problems

  • Overcoming the limitations of views
  • Triggers, function, and rules
  • Trigger is a type of function
  • Cannot update a view
  • Can use rules

CREATE OR REPLACE RULE "txnview_update" AS
  ON UPDATE TO txnview
  DO INSTEAD
  SELECT myfunc();

CREATE OR REPLACE RULE "txnview_update" AS
  ON INSERT TO txnview
  DO INSTEAD
  INSERT INTO txn (id) VALUES (NEW.id);

CREATE OR REPLACE RULE "txnview_update" AS
  ON INSERT OR UPDATE OR DELETE TO txnview
  DO INSTEAD
  SELECT 'No changes made. No update, delete, or insert allowed.' AS "Warning!";

oscon=> UPDATE txnview SET price = price + 1 WHERE id=123;
                     Warning!
------------------------------------------------------
No changes made. No update, delete, or insert allowed.


      Last             TOC             Next