I want to create a function that loops through a table and checks if a specific word exists in a text field. If it does, the function should set a Boolean field true. This is what I've come up with. I guess my execute command is wrong?
CREATE OR REPLACE FUNCTION insertCarBooleans() Returns void AS $$ DECLARE location RECORD; BEGIN FOR location IN SELECT * FROM Ownlocations ORDER BY id LOOP EXECUTE 'UPDATE Ownlocations SET Ford = true WHERE cars LIKE 'Ford'; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; SELECT insertCarBooleans()