plpgsql 函数。如何将值与一组值进行比较?

plpgsql function. How to compare value to set of values?

我有触发功能。 我想检查 status 是否是 (5,6,4,7)

之一
CREATE OR REPLACE FUNCTION a()
  RETURNS trigger AS
$BODY$
begin
    if old.status = (5,6,4,7) then
        do something.
    end if; 
    return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE

如何将其更改为正确的语法?

使用IN运算符:

...
if old.status IN (5,6,4,7) then
     do something.
end if; 
...

这是reference of this link

它只适用于 postgresql 9.x

CREATE OR REPLACE FUNCTION a()
  RETURNS trigger AS
$BODY$
begin
    if old.status = ANY (VALUES (5),(6),(4),(7))) then
        do something.
    end if; 
    return old;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE