The function definition must actually be RETURNS SETOF RECORD
not RETURNS TABLE
to produce that error.
If you actually needed to do it with RETURNS SETOF RECORD
, you must call it with a column-definition list, like the error message says:
a column definition list is required for functions returning "record"
See the documentation. You can either use OUT
parameters (equivalent to RETURNS TABLE
), or call with a col-list, eg:
SELECT name, suffix
FROM doc_codes(:deviceId) AS dc("name" TEXT, "suffix" TEXT)