Sql 在触发器函数中使用新变量
PostgreSQL 9.4 我正在研究以下触发函数:Sql 在触发器函数中使用新变量,sql,postgresql,triggers,Sql,Postgresql,Triggers,PostgreSQL 9.4 我正在研究以下触发函数: CREATE OR REPLACE FUNCTION check_inserted_row() RETURNS TRIGGER AS $$ BEGIN IF TG_OP = 'INSERT' THEN --Here I need to transform the NEW trigger variable --to an array of values or something else that can be ite
CREATE OR REPLACE FUNCTION check_inserted_row() RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' THEN
--Here I need to transform the NEW trigger variable
--to an array of values or something else that can be iterated over
--and check each value in it
--How can I do that?
RETURN NEW;
END IF;
END $$
LANGUAGE plpgsql;
问题是我不确定NEW
中会包含哪些列,因为以后可能会添加一些列。为了避免在任何时候重写触发器,我希望迭代NEW
中的所有列,并执行所需的检查
有可能吗?这可能会给你一些想法:还有这个:还有这个:这可能会给你一些想法:还有这个:还有这个: