📜  无法从返回复合类型的函数返回非复合值 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:05.149000             🧑  作者: Mango

代码示例1
--EXAMPLE OF A UPDATE FUNCTION WITH TRIGGER PLPGSQL

CREATE OR REPLACE FUNCTION update_aumentarpreco ()
    RETURNS TRIGGER
    LANGUAGE PLPGSQL
    AS 
    $BODY$
BEGIN
    IF NEW.ps_availqty = 2 THEN
        NEW.ps_supplycost = OLD.ps_supplycost * 0.10;
        RETURN NEW;
    END IF;
    RETURN NULL;
END;
$BODY$ 

CREATE TRIGGER update_aumentarpreco
    BEFORE UPDATE OF ps_availqty ON partsupp
    FOR EACH ROW
    EXECUTE PROCEDURE update_aumentarpreco ();