postgresql stored procedure update table values

Solutions on MaxInterview for postgresql stored procedure update table values by the best coders in the world

showing results for - "postgresql stored procedure update table values"
Stefania
09 Oct 2019
1CREATE OR REPLACE FUNCTION change_account_email(
2  IN oldAddr VARCHAR(50),
3  IN newAddr VARCHAR(50))
4RETURNS INTEGER AS 
5$$
6DECLARE
7  rcount INTEGER DEFAULT 0;
8BEGIN
9  UPDATE accounts
10     SET a_email = newAddr
11   WHERE a_email = oldAddr;
12   GET DIAGNOSTICS rcount = ROW_COUNT;
13   RETURN rcount;
14END;
15$$
16LANGUAGE plpgsql;
17