Declare and return a custom type in PostgreSQL function
问题 I found this article: http://wiki.postgresql.org/wiki/Return_more_than_one_row_of_data_from_PL/pgSQL_functions and I'm trying to use it as an example for my function. I am selecting different columns from different tables, and trying to return a set of records. Here's my code: CREATE OR REPLACE FUNCTION get_details_for_widget(widgetid integer) RETURNS SETOF widgetdetails AS $BODY$ DECLARE rec widgetdetails %rowtype; BEGIN FOR rec IN ( SELECT widget_details.id, widget_details.contact_id,