How can I get all column names and their values in trigger function because i need to validate all column values before inserting into the table.I have tried below code.If we know that column name means we can get the value easily by using NEW
object in trigger function as NEW.myColumnName
.But here I need to get the column name dynamically...
CREATE FUNCTION insert_update_validate() RETURNS TRIGGER AS $$
DECLARE
BEGIN
FOR i IN 0..(TG_ARGV-1) LOOP
IF TG_ARGV[i] IS NULL THEN
RAISE EXCEPTION 'cannot have null VALUE', NEW.TG_ARGV[i];
END LOOP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;