I have a simple function that outputs 2 parameters (in this example word and part_of_speech).
CREATE OR REPLACE FUNCTION findword(out word1 text, out pos1 text) AS $$
BEGIN
SELECT word, partofspeech
INTO word1, pos1
from content_word
ORDER BY RANDOM()
LIMIT 1;
END;
$$ LANGUAGE plpgsql;
If I use
SELECT * FROM findword();
I get expected results.
But when I use
SELECT (findword()).*
I get bizarre results:
tight | v
jury | j
as if word1 and pos1 were drawn from separate queries.
What am I doing wrong here?