I'm creating a stored procedure that changes email address, but I keep getting an error.
ERROR: syntax error at or near "UPDATE"
CREATE FUNCTION change(
IN oldAddr VARCHAR(50),
IN newAddr VARCHAR(50)
) AS
UPDATE accounts
SET a_email = newAddr
WHERE a_email = oldAddr;
I copied this from the textbook, but I don't think it works on PostgreSQL.
Please teach me how to correct it!
Thank you!
CREATE TABLE accounts (
a_id int NOT NULL PRIMARY KEY,
a_first_name varchar(25) NOT NULL,
a_last_name varchar(25) NOT NULL,
a_email varchar(50) NOT NULL,
a_password varchar(16) NOT NULL
);