CREATE OR REPLACE FUNCTION plpgsql_example() RETURNS integer AS
$$
DECLARE
    processed integer := 0;
    word text;
    newword text;
BEGIN
    -- restore fiveletterstrings to all lowercase
    UPDATE fiveletterstrings SET x = lower(x);

    -- uppercase the vowels
    FOR word IN SELECT x FROM fiveletterstrings FOR UPDATE LOOP
        newword := translate(word, 'aeiou', 'AEIOU');
        UPDATE fiveletterstrings SET x = newword WHERE x = word;
        processed := processed + 1;
    END LOOP;
    RETURN processed;
END;
$$ LANGUAGE plpgsql;
