📜  postgresql 存储过程更新表值 - SQL 代码示例

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

代码示例1
CREATE OR REPLACE FUNCTION change_account_email(
  IN oldAddr VARCHAR(50),
  IN newAddr VARCHAR(50))
RETURNS INTEGER AS 
$$
DECLARE
  rcount INTEGER DEFAULT 0;
BEGIN
  UPDATE accounts
     SET a_email = newAddr
   WHERE a_email = oldAddr;
   GET DIAGNOSTICS rcount = ROW_COUNT;
   RETURN rcount;
END;
$$
LANGUAGE plpgsql;