I know I've seen the answer to this here before but cannot seem to find it.... Can anyone give me the quick & dirty answer to passing a table name to a function like this: CREATE OR REPLACE FUNCTION tbl_toarray(name) RETURNS text $BODY$ DECLARE ROW RECORD; BEGIN SELECT ARRAY(SELECT ''id:'' || id || '', type_desc:'' || type_desc FROM $1) INTO ROW; RETURN NEXT ROW; END; $BODY$ LANGUAGE PLPGSQL; I'd like to be able to pass the function a table name and have the contents of the table returned as an array of text.... THIS WORKS: dmconfig=# SELECT ARRAY(SELECT '[id:' || id || ', type_desc:' || type_desc || ']' FROM lu_user_type WHERE active_flag); ?column? ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ {"[id:1, type_desc:System]","[id:2, type_desc:Company]","[id:3, type_desc:Administrator]","[id:4, type_desc:Employee]","[id:5, type_desc:User (standalone)]","[id:6, type_desc:Guest / Demo]"} (1 row) TIA.... Regards, Greg Patnude - Manager, Dynamic Applications Group Data Mosaics, Inc. 2406 South Dishman-Mica Road / Suite # 6 Spokane Valley, WA 99206-6429 VOICE: (866) 904-DMSF FAX: (509) 928-4236 ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your message can get through to the mailing list cleanly