Relative Content

Tag Archive for javascriptsqlnode.jspostgresql

PostgreSQL: Operator does not exist: character varying == character varying

I am working with PostgreSQL and Node.js and have created a procedure in Postgres to compare passwords then update it with a new one. Here is the code for that:
CREATE OR REPLACE PROCEDURE resetPassword ( userID UUID , confirmation VARCHAR(255) , newHash VARCHAR(255) , newSalt VARCHAR(255) ) AS $$ DECLARE oldHash VARCHAR(255); BEGIN SELECT password_hash INTO oldHash FROM Users WHERE uuid = userID; IF NOT FOUND THEN RAISE EXCEPTION 'No user found for: %', userID; END IF; IF (oldHash = confirmation) THEN UPDATE Users SET password_hash = newHash, salt = newSalt WHERE uuid = userID; END IF; END $$ LANGUAGE plpgsql;