postgresql - Can a PL/pgSQL function contain a dynamic subquery? -


I am writing PL / pgSQL function I function has input parameters which (indirectly) specify, which The table is to read the filter information.

The function embeds business logic, which allows it to select data from different tables based on input arguments. The function dynamically creates a subquery that returns filtering data, which is used to run the main query.

My questions are:

  1. Use a dynamic subqueries in a PL / pgSQL function, whether it is 'legal'. I can not see why not - but this question is related to the next one.

  2. The API or PL / PGSULE query engine has been cached or precomplied. Creates dynamic subqueries for query engine work that affects a function?


Comments