Dynamically execute query using the output of another query
问题 I have a function called generate_table, that takes 2 input parameters ( rundate::date and branch::varchar ) Now I am trying to work on a second function, using PLPGSQL, that will get a list of all branches and the newest date for each branch and pass this as a parameter to the generate_table function. The query that I have is this: select max(rundate) as rundate, branch from t_index_of_imported_files group by branch and it results on this: rundate;branch 2014-03-13;branch1 2014-03-12;branch2