Search Postgresql Archives

making trigger on delete, set 'affected rows' correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey list,

so I was wondering. Since many ppl depend on 'affected rows', we have here a trigger running on delete. It will update the table, and set certain fields to false on delete, return NULL - so it will look like:

CREATE OR REPLACE FUNCTION ondelete_update() returns trigger as
$_$
BEGIN
  IF OLD.foo <> false THEN
  EXECUTE 'UPDATE ' || TG_RELNAME || ' SET foo = 'true' WHERE rid = ' || OLD.rid ;
  END IF;
  RETURN NULL;
END;
$_$
LANGUAGE 'plpgsql';

Now, this on every delete will return 'affected rows count = 0'. C


--
GJ

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux