v_all_my_tables contains a single column (from charvar) which I'd like to loop through and run a select query on.
HeidiSQL creates the function using the code below. However, when I run routine, no results are returned and this error is logged
SELECT "myFunc"();
/* Unknown datatype oid #2278 for "myFunc". Fall back to UNKNOWN.
I'm new to postgres so I'm probably missing something obvious here. Thanks!
DELIMITER //
CREATE OR REPLACE FUNCTION myFunc()
RETURNS void AS
$func$
DECLARE
_tbl text;
BEGIN
FOR _tbl IN
SELECT table_name FROM v_all_my_tables ORDER BY TABLE_NAME ASC
LOOP
EXECUTE
format('SELECT distinct lastupdate FROM %I order by lastupdate DESC LIMIT 1', _tbl);
END LOOP;
END
$func$ LANGUAGE plpgsql;