I have a trigger function to test a table that has the following code snippet -
IF TG_OP='UPDATE' THEN IF OLD.locked > 0 AND ( OLD.org_id <> NEW.org_id OR OLD.document_code <> NEW.document_code OR -- Other columns .......................... ) THEN RAISE EXCEPTION 'Message'; .................................
So, I statically check the entire column value with its previous value to ensure integrity. Now, every time my business logic changes, and I have to add new columns to this table, I will have to change this trigger every time. I thought it would be better if I could dynamically check all the columns of this table without explicitly specifying their name.
How can I do that?
plpgsql postgresql
MD Sayem Ahmed Jun 21 '10 at 10:12 2010-06-21 10:12
source share